Thursday, March 01, 2007

Programmers Who Can't FizzBuzz

Jeff Atwood over at Coding Horror is "incredulous" at the experiences he is reading about on the blogosphere of applicants to software development jobs not being able to complete simple programming exercises during interviews. Allow me to add to his incredulous-ness.

I interview prospective co-ops where I work. These are generally Computer Science majors who have completed a technical ciriculum of at least four 10-week 4-credit classes in computer science, three of those classes in Java, one in C++.

So, when they show up for an interview, I expect they should be able to write some code on a white board. I use a few different programming exercises, one of which is a very slight variation on the FizzBuzz program. How I phrase the description for the program:


Write a program that prints the numbers from 1 to 100. For multiples of three (3) the program should print “Blue” instead of the number. For multiples of five (5) print “Green” instead of the number. For numbers which are multiples of both three (3) and five (5) print “BlueGreen” instead of the number.


Assuming it's a common language I know well enough to read, they are welcome to whatever language they'd like.

The first thing a good share of candidates tend to be tripped up by is remembering what the modulo operator is. Some developers also can't remember what the write/print line method of their favorite language is. Rather comically (to me, a coding dork), I had one candidate use a method he invented called writeln, although his program only worked if this "writeln" method did not append a new line (which is the convention of *ln methods).

Anyhow, this more technical stuff aside, they almost always get tripped up on figuring out that the solution invovles something more than a simple if (mod 3 case), else if (mod 5 case), else structure. They generally start off with that structure and then get flustered when either they figure out on their own (or I point out) that in some case their program will print both a color and the number or doesn't print out the "BlueGreen" case correctly.

For the heck of it, I pulled up a JavaScript Shell and pounded out a solution to time myself. In 65 seconds, I pounded out this:


for (var i = 1; i <= 100; i += 1) {
var res = '';
if (i % 3 == 0)
res += 'Blue';
if (i %5 == 0)
res += 'Green';
print( res == '' ? i : res );
}


Now, it's probably a lot easier to code on a computer than a whiteboard, and being in an interview adds stress and probably decreases how clearly you can think, so I'm not expecting 65 second answers from the applications. But, these Computer Science students pretty regularly fail to be able to correctly complete this really simple exercise at all.

It makes me wonder what they're teaching at my alma mater these days...

(Also, for the record, though pretty much all applications have taken CS 4, the C++ course at RIT for CS majors — and answer "yes" when I ask "so, you understand pointers" — I have yet to find an application that can answer #3 of Joel Spolsky's "Test Your Self" quiz. Not very encouraging.)

No comments: