Wednesday, August 31, 2005

Yippee!!!

The last post celebrated my first successful division 1 TopCoder match - this one celebrates my breaking into the ranks of the top 50 Indian TopCoders!

Ok, so I'm still ranked 48, but still, it's cause for celebration(while it lasts)! My highest rating yet - looks like all that div 1 practice paid off. Now I'd better start practicing 500 pointers if I want to keep my 1309 rating...Next SRM is in a week, and we have a nice long weekend coming up, so...

Remarks: The div 1 550 was one cool problem! I've got an idea of how to do it, though I haven't worked out all the details yet. That's next up on the agenda, but I'll probably read CLRS for a bit - in that sort of mood right now...

Might just get that GCJ shirt after all...let's wait and see. In any case, there's always next year's TCO, TCCC, GCJ - and maybe GICJ 2(the Indian edition of the Code Jam). Hopefully I'll be good enough to give people a run for their money by then!

And with that, this overly optimistic post comes to an end...

Tuesday, August 30, 2005

Murphy strikes...

Those who've read my last post(or who know me personally) will know that I was pretty fired up about doing the 1st Online Round of the Google Code Jam. After practicing dozens of division 1 problems in the TC practice rooms, I was ready to give it one hell of a whirl. Unfortunately, fate had other ideas...

The event was scheduled for 6:30 AM out here in India, and registrations closed at 6:25. Having done several SRMs at this time, I had a good routine worked out - wake up at 6, turn on the computer, wash up, come back and register, and then compete.

Everything went fine until the "Come back and register" part. The first thing I noticed was that my broadband connection was down. Congratulations Sify, you've done it again. Heaving a sigh, I switched over to dialup, which is at least reliable, though terribly slow in comparison.

Having connected, I fired up the Arena and...everything froze. Even the good old three fingered salute failed to work. Cursing at no one in particular, I rebooted, and repeated the process.

Five exactly similar tries later, my curses were no longer that vague...

And finally, on the last try, I glanced at the clock and knew that it was a lost cause - 6:27...far too late. And once again, it hung...Now thoroughly annoyed, I turned the damn thing off, swore eternal vengeance, and went back to sleep. Was in no mood to go to college after this crap...

I've sent a message to the Code Jam group asking if I've lost the t-shirt. Would be a real shame if I did - at my level, you know you don't have a shot at the onsite event, so it's all about the t-shirt, really...

Let's see what happens - after all, I'm dealing with a company whose motto reads "Don't be evil." Google, don't let fate cheat me out of the t-shirt, please!

And before someone comments to say "Look on the bright side," the only bright side I can see is that I probably should be able to stay on in division 1 for a while now. That practice should hold me in good stead - I hope. I still have issues with advanced recursion problems...

Let's see what happens...Until then, I'll stop racking up a phone bill and go read CLRS...

PS: I have no idea what's going on, but my TC rating is now up to 1242 from 1240(which jumped from 1238)...what are the admins doing anyway? Have they found more cheaters, or what?

Saturday, August 27, 2005

News

Being the overworked individual that I am, I've been neglecting my blog for quite some time. Apparently some of my readers have taken exception to this - or so Swapneel tells me - apparently quite a few people he knows read my blog. I'm not sure what kind of crazy people read my frequent outpourings of nonsense - but as a fellow lunatic, I have to keep them happy...

First bit of news - I officially declare myself as a contender for the title of the world's sleepiest person - courtesy of our college's bad habit of starting up at 8:00 AM, and my bad habit of coding late at night...It's pretty late as I write this, but I'm in a good mood, so I'll type away...

Good mood? Where did that come from, you ask? Two things, basically:
  1. Google Code Jam - I made it through the qualification round! After competing in the next round on Tuesday morning, I'm going to get an official "Google Code Jam 2005, powered by TopCoder" t-shirt. Plus I have a 1600+ rating there, so I get to see my name in yellow...
  2. The last match at TC - I moved up to div 1 one match ago, and competed as a blue coder in today's match a few hours ago. I was a little worried, since my rating was 1214 - right on the borderline. My fears of falling back to green today were unfounded though - even with my ridiculously slow solution of the 250 and a failed 500, I still went up 24 rating points to 1238. Hope this lasts. Practice, practice...
Also got hold of 4 recos from teachers for the MS apps - should manage 2 more on Tuesday. After that I can pick and choose, or whatever...

This weekend I intend to mostly do TC practice and relax - it's been a pretty tiring week. Sleep is obviously very high on my list of priorities...next is practicing for the GCJ - I know I don't have much of a chance of being in the lucky 250 who get selected for the next round - but I'm certainly gonna give it one hell of a shot...

Maybe I'll get around to posting on Code Monkeys. Haven't thought of a topic yet, but since I'm the (unofficial) algorithms guy, I might as well talk about algorithms, and maybe drag in Python too.

Realised one important thing over the last few days, and that is that there are very few things in life that compare to the sheer pleasure of writing code. Purely subjective viewpoint, of course...

Yawn...time to sleep now. Readers, leave comments some time - it's fun to know who reads your stuff...

Friday, August 19, 2005

Just missed...

For those who don't know, I narrowly missed qualifying for the TCO. The cutoff is a rank of 150 in your problem set - and I came along at 155...Looks like I shouldn't have spent so much time testing that 250 after all...

Apparently some cheaters were removed - I had a +1 rating increase from 1185 to 1186 overnight...Sadly there weren't enough of them!

Can't blame the admins, really - even if they suspect someone of cheating, they can't go ahead and disqualify the guy unless they're very sure. After all, it's better to let the guilty go free than punish the innocent...

Upshot: niphoton is the only MU coder to qualify. Our two blues have gone green again, and paradoxically, I'm the only guy whose rating increased...

The Monday SRM is gonna give me a good shot at div 1. The challenge isn't getting there, though, but staying there...

That's it for the TCO experience - on to deeper reflections...

The good thing about the TCO was that we ended up with 5 new practice rooms all at once. Working through them is pretty good practice, and I've learnt a few interesting lessons.

In a timed event like an SRM, usually you don't want to waste time thinking about the *best* way to do a problem - most of the time you can be content with the best thing that quickly comes to mind and works. I'd always thought that I could come up with something pretty quickly, and even though it wouldn't win any prizes for elegance, it would still fetch points...

Misjudgement. After I looked through a few of the solutions in Java by the reds, I realized that I hadn't picked up on the fastest ways of doing the little tasks that usually make up a big algorithm. For example, consider the matter of putting strings in a String[] array into a HashSet:

My code:
  HashSet hs = new HashSet();
for(String s: arr)
hs.add(s);

Red code:
  HashSet hs = new HashSet(Arrays.asList(arr));
That isn't much of a difference, but there's much, much more. Half the time, I don't look hard enough at the constraints and end up solving a slightly more general problem, and doing all sorts of useless checks that I don't need to...

Lesson two - use sentinels more often, especially in problems with grids - you end up saving a lot on boring boundary checks.

Lesson three - really need to work more on recursion...

Lesson four - using continue

Tuesday, August 16, 2005

It's been a while...

Looks like it's been some time since I last posted. In fact I probably wouldn't have blogged today if it weren't for an interesting incident that left me with a bit of free time. Details follow...

It's like this - usually on Independence Day or Republic Day, college is closed on both that day as well as the day after. Since 15th August(Independence Day) was yesterday, we fully expected a holiday today. Then we found out that there had been this circular that said that we did in fact have college on the 16th...Bummer, but what the heck.

So I arrived at college today, and saw the most astonishing sight - at least half of my class was standing around downstairs looking vaguely puzzled. I went over and was informed that people were "unsure" whether we had college or not.

Investigations followed, and eventually it turned out that the offending circular had been sent to the Electronics people - not to us. Somehow we'd gotten the idea that it applied to us...

And so we went back home...so here I am blogging away.

The TopCoder Open Qualification Round is tonight, so I've been practicing for that. I've done a couple of practice sets from previous qualifiers to warm up. Hopefully I'll make it past the qualifiers...I seriously doubt that more progress is possible, given my current skill level. Maybe next year...

There's an old saying - "The man that knows how to use a hammer sees nails everywhere." This is sadly true of me - whenever I learn a useful technique, practically every problem I see seems to use it, even if that isn't true...

In fact, just a few minutes ago I did this interesting 1000 pointer from one of the TCCC 2005 Qualifiers. My latest acquisition is breadth-first search - it's something I hadn't really used until now, and I figured it would come in handy in cases where depth-first search might time out. Naturally, I opened it up and saw a solution using BFS...

Well, not exactly. I first thought of BFS while I quickly typed out some of the preliminary stuff - helper functions, parsing the input, that kind of thing. But just as I was about to start up the BFS, I came up with this weird idea. I spent a stupidly long time on that(it would have been simpler than BFS, for one thing), without seeing that it was obviously flawed.

Eventually I came to my senses and went back to coding the BFS. Finished it off and it worked first time - yay!

Then I open up the match editorial and it turns out that DFS won't time out. Yeesh - what a waste - DFS is so much shorter in implementation than BFS...

And now to lunch...hope the TCO goes off well...

Thursday, August 11, 2005

NetBeans rocks...

There's an old saying which goes something like, "For every door that closes, another opens." Just realized how true it was today. As the last blog post mentioned, I'm down with a viral infection, so no college for me(ok, so this isn't really a bad thing)...Worse still, JCreator - the Java IDE that I usually use - started acting funny today. Every time I try to save something, it pops up this little dialog saying "The given task was completed successfully." Needless to say, no changes are saved...

A reinstall didn't work - that was how I fixed it the last time this happened. Since I wanted to do the practice rooms for SRM 258, I fired up NetBeans - made some changes to my FileEdit config, and got to work.

I was astonished. The last time I'd used it, I hadn't been very familiar with Java - plus my experience in Java IDEs up to that point had been limited to TextPad(which isn't really an IDE, just a text editor with indentation and higlighting...). Back then I wasn't very impressed. Now it feels like a revelation.

I'm seriously contemplating switching over to NetBeans for SRMs, especially because I don't want to run into a JCreator bug in the middle of the TCO qualifiers. Not that I have that much of a chance, but you never know...

Earlier today I was reading up on Cantor's Diagonal Argument after brushing up on Turing's proof of the unsolvability of the Halting Problem. I googled it, and to my astonishment, I found a bunch of pages claiming that the diagonal argument was fallacious - which also kills off Turing's proof and Godel's incompleteness theorem(I'm not perfectly sure about this bit, though)...And more fundamentally, all the stuff that Cantor proved about infinities would be thrown out of the window as well.

They're obviously wrong - but are they serious or joking?

This is why Computer Engineering really sucks - you miss out on all the cool maths that Computer Science people learn. No wonder I'm still green at TC...

NetBeans 4.1 downloaded. Off to install...

Wednesday, August 10, 2005

Down and out...

Ladies and gentlemen, it's that time of year again. Viruses(the biological kind) are roaming the city, preying on unsuspecting victims - in this case, me.

Last night I had one of my occasional sinus attacks. That wasn't too bad - after almost ten years of living with flawed nasal architecture, I've gotten used to it. Unfortunately, I was completely unprepared for what happened the next day...

Getting up at 6 AM four days a week tends to turn you into a very good sleepwalker - most of my early morning routine is performed in a stupor of sorts. I only really wake up after I've had my head under the shower for about five minutes...

Today morning was no different, and I went through the motions as usual, only vaguely aware of my body protesting about something. By the time I was out of the shower, though, I was feeling rather uncomfortable - fogged out is probably the right term. I chalked it up to lack of sleep and went on - for about five minutes. Pretty soon I'd realised that something was wrong. Solution: Come home early from college, after wrapping up the annual bureaucratic chore of getting some stuff verified.

Off I went to the bus stop. I'd just missed the 7:20, so I had to sit and wait for the next one. Ten minutes later, I was heading back home, having discovered that moving was not something I was feeling up to that day...

Got back home and slept for four straight hours. I was feeling a little better when I woke up, but my nose wasn't exactly in midseason form, and my ears were blocked. My throat was even worse - there's nothing more annoying than pain when you swallow. To add insult to injury, I found out I had a fever too, and a mild headache above the eyes...To sum it up, I was pretty miserable.

A few hours later the situation had improved - my white blood cells were clearly kicking ass, and my nose and throat were a lot better. Naturally, I did the only sensible thing - turned on the computer, fired up MusicMatch and pulled up Diaspora by Greg Egan. Popped a Crocin too, and the effects were pretty evident after a while - I had at least some of my energy back.

Unfortunately, this thing seems cyclic - I have a feeling my nose is about to start up again, and my energy levels have dropped once more, even though I've done nothing except maybe walk to the doctor two buildings away...

The diagnosis is viral fever, of course - what else keeps on coming back year after year? Bigger and better too(or maybe just better) - mutations take care of that...

Not sure whether I'll make it to college tomorrow - this stuff is usually real bad in the morning. And the last thing I need is to go to college while sleep deprived and on antibiotics. Plus I don't fancy standing in line either...

Thite says that two of his friends came down with something a while ago too - apparently the thing runs its course in about 3 days, with rest and medication...

An odd thought just crossed my mind. I quote myself, "I haven't been properly sick in years - just out of sorts for a day or so..."

Looks like the fever's coming back up...

Monday, August 08, 2005


My sister showing off her 29 friendship bands. The nonsense scrawled on her forearms is from half a dozen friends who ran out of bands...She's got a few tied around her fingers too... Posted by Picasa

An interesting Sunday...

This Sunday was supposedly the *official* version of Friendship Day, but anyone who's ever been to college in Mumbai knows that this particular event is celebrated at least three times a year...In fact, I didn't really know that there was such a thing as an official Friendship day - somehow I'd come to the conclusion that it was one of those social consensus things that happen every now and then...

Anyway, on an MSN chat on Friday night, Thite suggested a geek meetup on Sunday. This idea went down pretty well with all of us, and we duly turned up at Inorbit mall for pizza at - you guessed it - Pizza Hut...

The aforementioned *we* were Thite, Sagar, Swapneel, Gautam, and yours truly...The last two chaps haven't been mentioned on the blog before - Thite introduced them to us yesterday. And I'm also the latest member of the new Code Monkeys blog! Well met, fellow code monkeys...

Anyway, Gautam ended up leaving early - he had to get to a party organized by his girlfriend's mom - weird...Before he left, though, he fervently entreated me not to fall into the Ruby trap - Thite and Swapneel both do Ruby, and he's the only one who does Python. Since I also use Python frequently(hell, I keep it open during SRMs...), he was hoping to equalize the odds...

Still gonna take a look at Ruby, but since our final year project involves Python(well, Jython actually), I won't be shifting over any time soon. The language seems a little weird after so much C++, Java and Python. Plus I want to learn LISP sometime, and I have Prolog this semester...

Sagar suggested catching a movie, but we decided to give it a miss when we found out that we'd be missing at least 10-15 minutes of it...After a short wait at Barista, we decided to check out MovieTime and see if there were any movies worth seeing. Turned out that The Island was scheduled for 8:30 PM, but since we didn't have that much time, we decided to head back home...or so we thought.

Thite had to stop off at Sagar's house to pick up a book for DCOM. I decided to come along - didn't really have anything better to do.

We were supposed to make a brief stop - what happened was that we ended up watching a small part of Ferris Bueller's Day Off, listening to Sagar's favourite song(it's in Swahili, and IMHO, sucks big time...) and eventually saw two episodes of Coupling. Definitely the most hilarious stuff I've seen in years - just tremendous...Have to remember to grab some of the episodes from Sagar...

We eventually managed to get away, but only after 10 minutes of politely refusing Sagar's mother's near imperial commands to stay for dinner...She actually handed us a bunch of chocolates to make sure we wouldn't *faint* on the way - the sad part is that I'm not quite sure if she was serious or joking...

What I thought of it all
I'm not a very social person by nature...in fact, I find most social occasions tremendously boring. Not that I hate socializing per se - in most cases, I just don't give a damn. Given my usual reaction to these things, I was surprised to note that I rather enjoyed myself. Being the analytical idiot that I am, I couldn't resist figuring out why...

Two words: the company.

99% of the boredom I experience at social events is the people. I don't make small talk very well - I prefer to talk about bigger issues or about tech stuff...Even the little small talk I make inevitably turns into something bigger...Most people can't take this - most of them fall into one or more of the following categories:
  1. They're shallow and so don't care about what I'm saying.
  2. They're shallow and so don't get what I'm saying.
  3. They don't appreciate subtlety, so I turn them off.
  4. They're not techies, so they have no idea what I'm saying.
  5. They're really concrete minded people, and don't like the abstractions I favor.
  6. They're just plain dumb.
Sunday's group was all tech - so we could actually discuss interesting stuff. We ended up making jokes about wireless tech, dumb teachers, families who constantly have to be spoon fed technical stuff, call center horror stories - in short, the kind of stuff that non-tech people("Muggles") can't really appreciate. As you might(or might not) expect, we had a whale of a time...

Of course, if I'd started talking about the non tech stuff that often occupies my thoughts, even they would have crumbled. People who actually get that stuff are much rarer than techies - at least in my circle. The ultimate are the vast majority of my classmates - they don't know any tech stuff aside from what they've been taught, and they don't know much about other things either. Go figure...

The remainder - people who get everything I say - are practically non-existent. Since my thoughts are connected rather weirdly, even tech brings non tech stuff to mind - I often end up pulling information from stuff I've read about history, or mythology, or some language or the other - all the weird stuff that I know and which really bores my friends...

Just noticed an interesting thing - while tech often brings non tech to mind, the converse is very rarely the case. Looks like it's a directed graph :)...

Decided to start doing some Div 1 probs - I'll need them for the TCO qualifiers, and I'm getting tired of div 2. The probs aren't that challenging anymore - leaving aside the occasional silly mistake, it's practically guaranteed that I'll crack at least the easy and medium - and the hard in most cases. Now if only I can go blue and stay blue...

Back to my Intelligent Systems assignment now. Work, work...

Thursday, August 04, 2005

Voice cancellation and my weird taste in music

My sister Lubna has this weird habit of doing a bad karaoke act by turning on voice cancellation in the speaker settings and playing any song she (thinks she) can pull off. She's been doing this for at least a year now. Now she's started this new thing where she cancels the singer's voice, but doesn't sing herself(Thank God...) - instead she tries to pick out the different instruments being used.

She was doing this a few minutes ago, and asked me for suggestions. Now I have rather weird musical tastes, and it so happens that 3 of my favourite songs are in Japanese. And no, I don't understand them, even though I remember them word for word...

Anyway, there's a particular favourite of mine that goes by the name Zutto Kimi No Soba De. I've always admired the music of this song - it's pretty complex, in the sense that if you listen closely, you can hear 3 different tunes. They are similar, but not exactly alike. What I really love is the way they seem to blend in when you listen to them. Combine that with the superbly trained voice of the main singer, and you get one hell of a song.

To cut a long story short, I told her to try this song out. The effect was unbelievable.

Though voice cancellation removes the voice of the main singer, you can hear the chorus very clearly - something that's almost impossible in the uncancelled version. The lead singer just drowns the entire chorus out otherwise, so you only get a sort of vague hint of them crooning in the background.

So we played the song, and whoa! The chorus was amazing! They sang the same stuff as the lead singer, but with a slightly different tune(key? pitch? Really need to figure out what these terms mean...).

I really don't remember seeing this kind of symmetry in anything else - except mathematics - no wonder they say music and math are related...Just think about it - 2 or 3 different instruments playing closely related(but not exactly similar) tunes, and all the voices in the chorus singing away in another slightly different tune - and all that melding together seamlessly with the voice of the singer to create one fantastic piece of music...Terrific.

I'm pretty sure that composers have known about this melding effect for a long time - the words 'harmony' and 'counterpoint' come to mind. Sadly, as far as music is concerned, they're just words to me, and I'm too lazy to look them up...

And here's a question for anyone who understands filters or digital signal processing. I figure voice cancellation is accomplished by filtering out most of the frequency components of human speech. What I notice is that some instruments in some songs become noticeably louder when I cancel voice - why is this? I'm pretty sure it's not my ears playing tricks on me...

TopCoder update: I managed all 3 problems in SRM 256 - unfortunately, my 550 failed. I still haven't tested it to figure out why. Still, my score was good enough that I managed to place 5th in the room, and my rating is up 44 points...

Was a bit depressed at first, but I realized later that this was actually a good thing. College attendance worries mean that I'll be missing the next two matches. This means the next event I do will be the TopCoder Open Qualification Round - and I'll be doing it at the top of division 2, rather than at the bottom of division 1! Better chances of advancement, and the chance to win some dough :-D...

PS: This does NOT mean I'm happy about having lectures at 8 in the morning. Who the hell wants to wake up at 6 AM four days a week, and then attend college until 4 or 5 PM? No wonder most people look terribly sleepy by Friday...

Monday, August 01, 2005

Why I don't think much of government...

This is actually a reply to Sagar's comment about my low view of the government. You can see the original post here, and the comments are below that. It deserved more than a few lines of text in reply, so I've given it a post of its own..

It's not that I hate governments - it's just that I have a rather cynical view of them. There's a gaping flaw in our current model of democracy - or rather, a lesson which people often learn subconsciously, but which needs to be explicitly incorporated into the workings of government. The lesson is - always distrust the people who govern you. Never give them the benefit of the doubt - ever. Failure to do so invariably results in either:
  1. Dictatorship/Oligarchy/Plutocracy, or
  2. An all powerful bureaucracy.
Trusting those who have power is a bad thing - either they misuse it, or they make human mistakes which go undetected and end up amplified because of the unquestioned power. Both ways, the governed lose...

My views on this are heavily influenced by Chapterhouse: Dune - see the discussion between Lucilla and Great Honoured Matre(the 'Spider Queen')...

BTW, I have similar views on laws - or rather the stupid view that goes 'The letter of the law must be observed.' Such a statement doesn't aid justice - it turns it into a side issue. As Dune's Bene Gesserit say, the problem with laws is that they have no human understanding...

It just goes on...

It's official - the weather god who takes care of Mumbai's weather has gone certifiably insane. The rain is practically a constant feature now - it never seems to stop, just varies between 'not-so-mild drizzle' to 'killer thunderstorm'...

I'm told the government has declared an indefinite holiday for now - people aren't willing to risk sending their children to school, or risk their cars by travelling. The trains are working intermittently - every so often things go crazy in some part of the city and the trains stop there, which eventually propagates all over the city. As I write, the harbour lines are down, and I don't think the Central lines have worked properly since Tuesday. I don't really know anything about the buses, but BEST lost quite a few in the Tuesday floods, so there's no way they can operate at full capacity in this sort of weather. As usual, people have been asked to stay indoors as much as possible...

The authorities have finally gotten off their asses(mostly) and started doing stuff. In fact, the traffic cops have put in a stellar performance in their yellow raincoats. Nice work guys, keep it up...

And the radio stations - great work done there - they've been helping out people with directions on the road and giving constant updates on conditions in different parts of the city. Plus they play some pretty good music too...

Meanwhile, I've been messing with graph algorithms for the past few days - ended up learning and coding a whole bunch of things - shortest paths, minimum spanning trees, topological sort - the works. Time to do a bit of the theoretical stuff - a weird combination of discrete math, common sense and pseudocode...

Seems like I forgot to mention my last SRM - cracked all 3 probs and fixed the dive my rating took after the power failure on Tuesday. It was a pretty straightforward problem set, but a bunch of new members were disqualified for cheating. Yeesh...Come on people, why mess up such a fun competition by trying to cheat?

Back to work...