I just read “Why Can’t Programmer’s Program” over on Coding Horror. Out of sheer curiosity, I googled “Fizz Buzz C#” just to see what some people had engineered. The idea of the “Fizz Buzz” test is to provide a starting point to prove you can write working code. Nothing complicated, but apparently 199/200 applicants can’t even do this.
I do hiring for a few of my clients, and I’m pretty much in agreement with the general community sentiments. I’ve had people across my desk quite a few times with what look to be quite distinctive backgrounds, only to fail at simple day-to-day ASP.NET coding tasks. I would recommend to anyone involved in recruiting to make their candidates sit a simple skills test to determine whether they can actually code before putting applicants in front of a client. For discussion, I submit my own Fizz Buzz answer.
using System; public class Program { public static void Main(string[] args) { for (int i = 1; i < 101; i++) // i <= 100 is also fine { Console.WriteLine(FizzBuzz(i)); } } public static string FizzBuzz(int i) { if (i % 15 == 0) return "FizzBuzz"; if (i % 3 == 0) return "Fizz"; if (i % 5 == 0) return "Buzz"; return i.ToString(); } }
That took 90 seconds to write, and we can have a conversation about why I’ve factored FizzBuzz as a method (easy unit testing), why I’m using multiple exit points (because I think in this case it adds clarity) and why I’ve not made the amazingly trivial mistake (which around 50% of the google results did) of writing i < 100.