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!
Thursday, February 23, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment