Introducing FizzBuzz
When we interview programmers who will write code to help with testing, we like the exercise FizzBuzz. The exercise requires the programmer to understand conditionals (which are if
statements), looping, and the modulus operator (which is the remainder in division). Let’s see what a typical assignment might look like.
In the children’s game of Fizzbuzz, players rotate, keeping a count that starts with one. If the next number is divisible by three, players say “Fizz.” If it is divisible by five, they say “Buzz.” If it is not divisible, they say the number. The goal is to write a computer program that runs on the command line and takes in the number to count up to in FizzBuzz math, then puts the output on the screen.
Matt wrote up an implementation of FizzBuzz in Ruby. Instead of the most powerful constructs of the language, he used the ones that were easiest to read. The following output could be “tighter,”...