Thursday, February 23, 2006

Off to Bangalore

I'll be leaving for Bangalore tomorrow, for Stage II of Code4Bill. Let's see what Microsoft has in store for us. After all, the worst they can do is find out that I'm running Linux...

OS Update: Now on Ubuntu 5.10.

Now reading Eric Raymond's The Art of Unix Programming. Seriously not what I should be doing for an interview with MS, but the chances of qualifying were always infinitesimal anyway. I'm rather astounded that I've made it this far - India must be suffering from a terrible shortage of skilled computer science people...

WTF of the week:
For our robotics practicals, we have to write some code that converts a grayscale image to binary. This involves constructing a histogram of the image, using which we figure out a threshold value. Two guys from my class came up with a rather inspired way of doing this.

(For those who don't know, an image histogram essentially contains a counter for each possible gray level in the image, indicating how many pixels of that intensity exist in the image. The obvious thing to do is create an array of integers, indexed by gray level. So the number of pixels with intensity i is stored in cnt[i], and then you can just plot the histogram. Nice and general. Also blindingly obvious, or so I thought...)

The guys in question clearly believe in working hard, and their code reflects that. Right at the beginning you see a line which exemplifies the style of their entire program.

WTF #1:
int c1, c2, c3, c4, c5,...., c16;

WTF #2 is peripherally visible in WTF #1 - they've numbered their gray levels from 1 - 16, completely forgetting the fact that they're numbered from 0 - 15, so you can store gray levels in 4 bits. Under normal circumstances, testing would catch this error, but they'll come up with their own tests, so they won't have any problems....

Then again, they just might - I wouldn't be surprised...

WTF #3:
for(...)
for(...)
{
if(img[i][j] == 1)
{
cnt1++;
}
else if(img[i][j] == 2)
{
cnt2++;
}
....
....
....
}

Need I say more? Yep, since I have a real sadistic streak(fiendish grin)...

WTF #4:
The logical culmination of all the previous wtfs, catalyzed by the existence of primitive copy and paste facilities in the obsolete edifice that is Turbo C++ 3.0.

Draw line using c1
Draw line using c2
Draw line using c3
...
...
...
Draw line using c16

Graphics savvy readers should mentally replace each "Draw line..." with a call to line(x1, y1, x2, y2).

And that, ladies and gentlemen, is a prime example of the kind of matchless talent we see these days. I couldn't equal such greatness even if I tried.

*Sigh* - at first I thought that these two unfortunates had forgotten about the existence of arrays and loops, but a closer look revealed that they had in fact used both in their programs. Apparently thinking too hard causes selective amnesia in some people...

And now to finish packing...I'll be back on Sunday evening, so expect a post on the M$ experience in a couple of days. Ciao!

Sunday, February 19, 2006

Blogging from Linux

This blog is brought to you by Ubuntu Linux 4.0, courtesy of a failed hard disk and a strange concatenation of circumstances, which will be explained in excruciating detail below.

For the past few days, I've been having problems starting up my computer. It's been rather like a game of Russian Roulette, since I never could tell which startup attempt would result in the blue screen of death. When this insanity finally started affecting Firefox and assorted other applications, I decided it was time to reinstall Windows.

Now, for some reason my dad lives under the mistaken impression that the techs who handle his office comps know a bit more about these things than I do. Evidence to the contrary fails to change his mind, even when presented with innumerable situations like this:

Me: The comp is busted. I'll just do x and fix y.
Dad: No no, I'll call one of the techs over. Let them decide.
(A few days later, the tech arrives. After a long examination...)
Tech: The comp is busted. You need to do x and fix y.
Dad: Go ahead.

At this point, I usually struggle to keep from saying "I told you so", with limited success.

Over time, I've gotten used to this sort of thing. At the very least, it saves me some donkey work, though sometimes I get impatient and take matters into my own hands.

This time, I began to suspect hard disk problems when a scandisk informed me that there were bad sectors on my disk, followed by a barrage of blue screens and disk i/o errors. My dad thought there was a virus, and then proceeded to blame games, chat programs, P2P, and so forth. I stopped listening to these improbable ideas years ago, but they're still faintly amusing. It's interesting to note how non-technical people just don't seem to have any sense of context when it comes to these things. Come to think of it, that's often true of technical people too...

Anyway, I didn't have another hard disk to backup my data(grrr....) so I was forced to wait for the chap to come over from dad's office. He turned up and said that a simple reinstall could fix things. No need to format, though naturally most applications would stop working and would need to be reinstalled. He proceeded to do just that.

It worked like a charm for about half a day. I'd already begun to believe that it was just a case of some program crashing and corrupting some system files or something, when out of the blue, it crashed again. *Sigh*...

So yesterday the tech turned up, figured out that it was a disk problem, and left me a temporary hard disk on which he hastily installed windows. Thankfully the old HD is still under warranty, so I should get a replacement pretty soon.

Hawk eyed readers will have noticed my usage of the word 'hastily' in the previous paragraph. Translation: he installed Windows on a 2GB partition, leaving only about 17 megs of free space on that partition. The others, of course, were huge in comparison, and he told me to install new stuff there. Fine, I said. Turns out I spoke too soon.

Some time after it was done, I started installing my ISP's download client. Now these buggers have a strange policy of installing a tiny antivirus prog along with their dialer. Slightly annoying, but not a big problem by any standards. The real WTF is the useless programming of their installer. Not only does it insist on installing to the windows partition, it attemps to install the antivirus there too! There isn't even an option to change the install location, and when you run out of disk space, it's too dumb to tell you. Yeesh. If you wanna do something right, you've gotta do it yourself...

The obvious solution is to use Partition Magic, and resize the partitions. And here we run into the Catch-22 for the day, viz. how the hell am I supposed to download partition magic if I can't get on the internet?!

There are dozens of other solutions, but one I liked presented itself this morning, when I remembered the old Ubuntu CD lying in my drawer. I proceeded to install this, and voila - i was on the net again!

Now I just have to wait until my new hard disk turns up. Until then, vive Linux! And when it does, vive Linux again! For some reason, the feel of Linux is really conducive to coding. I'll be doing my next SRM from Linux, just to see if it helps.

Code4Bill update: I'll be flying to Bangalore this Friday, with Arijit and Vishwesh. Nishant will fly Indian Airlines, since he gets free tickets. He'll be meeting us in Bangalore. It's turning into a MU TopCoder's meet, really. Microsoft is kinda taking a back seat in my mind, and I don't have any illusions about being one of the final twenty with my lack of MS specific skills. The smart money is on Arijit, who seems to know every technology under the sun, and Nishant, who can do it on sheer brain power alone.

And now, I shall go and take a nice warm shower. Toodle-oo, people.

Wednesday, February 15, 2006

Monday, February 13, 2006

Life is good!

I've been experiencing an incredible streak of good luck over the past few days. It's as good as anything to blog about, so here goes...

First off, universities have finally started replying. I've only got two replies so far, but one of them has been incredibly positive. The University of Central Florida wants me in their CS Ph.D program, and what's more, they're giving me an assistantship too! It's a pretty good program, so unless something even better turns up, I might just be in Orlando half a year hence. My childhood ambition of visiting Disneyland might actually be possible now...;)

Of course, it is a Ph.D, so I'm scared out of my wits. On the other hand, one look at the stuff I'll get to learn sends my enthusiasm levels through the roof. Besides, I'm not exactly dumb, and it's a fun way to spend the next few years...

All this exultation is somewhat premature, since I still have to hear from the rest of the univs, but it's good to have something in the bag, so to speak.

At this point, a few people will be wondering why I haven't mentioned the reasons that they would undoubtedly find most convincing for going to Florida. For their benefit, I'll mention a bunch of keywords which should keep them happy. Here they are: tropical weather, theme parks, beaches, babes. Putting these together is left as an exercise to the reader.

Ok, that's it for the first piece of good news. On to the second...

Remember Code4Bill? Well, it turns out that despite my useless performance in all 3 rounds, Microsoft is convinced that I'm among the top 5% of all Indian students(their words, not mine). So either next week or the week after that, I'll be going over to Delhi or Bangalore to be interviewed by a bunch of Microsoft people. They're only picking 20 people for the internships, so I'm probably out - after all, there have to be 20 people in this country smarter than I am...Still, it looks great on a résumé, eh?

I finally made it to USACO section 3.3. The problems look rather scary now, so I have a feeling it's gonna be slow going.

I just hope this streak of good fortune doesn't suddenly reverse itself(to preserve balance or some such thing). I'm rather terrified of that happening, especially since the results will be coming out soon...Anyway, there's no point in worrying about that.

Half a day of boring lectures tomorrow...thankfully I have several USACO problems in my head to occupy me. Time now to hit the sack. Toodle-oo.