FizzBuzz
Wow. I read an article at Coding Horror stating that a lot of programming job candidates cannot write code at all. No kidding? I used to do a lot of interviewing at some of my previous jobs, and I usually had a great group of candidates. We were a little harsh on programming puzzles and could have gone more gently, I suppose. We had good candidates and hired the best of them (or so I think).
I remember one guy who was given a bit of code to read and the question was “what does this code do?”. I remember his answer, “it’s C, so it could do anything at all. There is no way to tell without firing up the debugger.” I thought it was the worse answer I’d ever heard. The problem was a two-or-three line example. I remember that guy being hired against my recommendation because of talents other than programming, and maybe that turned out okay. I don’t recall.
But just in case someone asks, here’s some python:
for number in range(100):
value = \"\"
if number%3==0: value += \"Fizz\"
if number%5==0: value += \"Buzz\"
print value or number
Maybe it’s not elegant, but it is a program.


