There’s a lot of debate over the best way to interview and screen developers. It turns out that many people claiming to be software engineers - particularly those pushed upon you by recruiters - tend to be unable to write code in any shape or form. This sounds hard to believe, but it’s absolutely true. You wouldn’t believe how many interviews I’ve had to cut short because it became rapidly apparent the candidate wasn’t able to write code (depressingly, some of those candidates had masters from reputable UK computer science departments, but more on that another time).
About six years ago, the FizzBuzz test - a simple screening question for programmers - was highly publicised by Jeff Atwood on his blog. Programming questions in interviews are not new. But whilst Google, Facebook, and the like might ask you complex graphing problems, FizzBuzz just tests one thing: do you know how to write a loop, and how to write a conditional. Here’s the question:
Write a program that prints the numbers from 1 to 100. However, for multiples of three print “Fizz” instead, and for multiples of five print “Buzz”. If a number is a multiple of both three and five print “FizzBuzz”.
One problem I’ve always had with FizzBuzz is that although it weeds out the really bad candidates, it’s both a little clichéd, and also has very little scope for further discussion. Instead, when I interview people - for both full time and contract roles - I ask them my own ‘FizzBuzz’ like test, but with a key difference. Here it is:Prime Numbers
Write a program that prints out the prime numbers from 1 to 100.
I really like this question as an interview screener. Why? Because it’s only marginally more complex than FizzBuzz (you need to know what a prime number is), but it’s also far more flexible. It tests:
- Knowledge of for loops
- Knowledge of conditionals
- Integer math
If a candidate solves it immediately, you can start talking about ways to increase efficiency when dealing with an increasingly large range (say, all the prime numbers from 1 to 1,000,000). This could range from really straightforward optimizations through a full sieve implementation.
And before you say “wait, that’s far too simple”: perhaps you haven’t had the pleasure of interviewing in the wild. I’ve had candidates who didn’t know what a prime number was, who implemented it by working out the prime numbers up to 100 by hand and pre-populating an array with them…seriously mad stuff. It’s a great question, and I’ll be sticking to it (…or will I? I probably will, but if you ever interview with me and have read this post I’ll expect something pretty impressive!)