Fizz Buzz is a well known programming exercise, aimed to establish simply whether someone has a basic grasp of programming concepts or not. It’s the MOT test of programming exercises, and has sparked interesting debate in the past.
Here’s an example of a Fizz Buzz question:
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
I was interested in uncovering any latent programming aptitude amongst NM’s non-programming collective, so I asked some team members if they’d like to have a go at solving Fizz Buzz.
Clive took the bait, and his interpretation is below, but before reading any further, perhaps you’d like to have a go at solving Fizz Buzz as well? It’s OK, I’ll hang on for you…
OK. Welcome back. Here’s Clive’s version, which I find fascinating…
Clive forgot to stop at 100, but apart from that the implementation’s correct. What I find fascinating is that Clive’s construction of the loop, he derives each iteration manually, whereas a seasoned programmer would simply accept the loop as a given and start from there. This may be why so many non-coders find it so hard to start coding, not knowing what you get ‘for free’ and how much you can essentially take for granted. (As an aside, this also reminded me how easy it is to dismiss the monumental effort that has gone into the creation of the technology that surrounds us, and how we so often stand on the shoulders of giants. An idea that has been explored before brilliantly in the The Toaster Project).
I also love that Clive grokked the idea of working at a “meta” level, so instead of just writing instructions like:
He’s actually gone to the effort of uncovering and encoding the underlying logic, which is great!
Anyway, I find this stuff fascinating, but maybe it’s just me!
Feel free to post your Fizz Buzz solutions below… Here’s mine. :)