Over a year ago, I mentioned FizzBuzz as a basic competence screen during interviews. At the time, I said: “My only real quarrel with FizzBuzz is that, at this point, any developer worth their salt is familiar with it.” I seem to have been wrong, becuase I keep running into coders who definitely are competent, and who haven’t encountered it yet.
That’s fine, because FizzBuzz does have a few nice qualities as a test.
It’s Language-Agnostic
It makes sense for someone to code a FizzBuzz in anything from JavaScript to Haskell to C++ to Ruby to Python to assembler (pick your instruction set). The same cannot be said of various other standards, like “Reverse a string in-place” (which takes a bit of thought and care in C, and so makes a good test — but is utterly trivial in languages like Perl or PHP that have built-in string-reversal functions) or “connect to a webpage, count the frequency of words in it, and output them sorted in descending order” (which makes sense in scripting languages with well-known HTTP or cURL packages, but is far too big to make a decent whiteboard question in ones like C or C++).
It Doesn’t Require Memorization
There are some questions that require that the applicant knows a particular library call or special function. In the previous paragraph, I mentioned Perl’s reverse() and PHP’s strrev() — those aren’t what I mean, because those are pretty core functions. Those are the sort of thing anyone who does any text manipulation will have memorized, because they use it every day. But what about some of the more obscure ones, like PHP’s strncmp()? If you ask a question that requires it, you’re basically asking your applicant, “Have you heard of this really obscure function?” (In the case of languages like PHP, with its over-3,000 core-level functions, this is particularly evil, but the same results can be obtained by using a little-known CPAN package, C++ stdlib function, or Java Class Library function.)
FizzBuzz doesn’t require any weird functions to solve. It’s nothing but math, plus a for loop and an if/else. The most obscure thing in it is modulo arithmetic. And sure, maybe the applicant might have forgotten what the modulo operator is, because it’s not the sort of thing most people use every day.
But you can still solve it without the mod operator. Read More