This question popped up in my daily email digest from Quora:
Are there really programmers with computer science degrees who cannot pass the FizzBuzz test?
Ok. I’ve been a professional software developer for 22 years (not including hobbyist coding before graduating and starting work) and I have a Computer Science degree. What is this FizzBuzz test? Now I’m curious. I admit it’s been a while since I’ve been for a job interview, but I’m aware of the current trend to ask interview questions to determine a candidate’s ability to solve problems. ‘FizzBuzz’ refers to a school game where you as a group you take turns in counting, but replace ‘Fizz’ if the current number is divisible by 3, ‘Buzz’ if divisible by ‘5’, or ‘FizzBuzz’ if divisible by both (or something similar, along those lines).
So the interview question is: write code that counts from 1 to 100, and outputs the number, or Fizz, Buzz, or FizzBuzz according to these rules.
The point of the question is not to write the most elegant, or brilliantly clever solution to the problem, the point of the question is to establish whether the interview candidate can write code demonstrating elementary software development concepts such as iteration and boolean logic conditions. If you’ve ever conducted technical interviews before then you won’t be surprised that you will come across candidates who say they have x years of experience in coding in language XYZ, but it’s pretty obvious that they can’t code anything at all. Jeff Atwood commented on this in a post here.
My first attempt at writing this straight up with little thinking, I wrote this:
Once I’d written this, it concerned me that I had the mod 5 test twice, so I tried to optimize the logic to not repeat this test, and my second attempt resulted in code that didn’t write out the correct expected results. I think this is the second part of the point of this question – it’s a puzzle where it appears there should be an elegant solution, but there really isn’t. Gayle McDowell’s answer to this question on Quroa calls this the ‘Smart Person’s Mirage’ – it seems like there should be a smart answer to the question, but there really isn’t.
Other than being lured in to try and answer this question myself since I’d never heard of this before, I guess the lesson here is that it’s not really the answer that counts, it’s how you approach the problem, and the process you take to solve the problem.