Fizzbuzz

Jeff Atwood, who writes the blog Coding Horror tweeted about issues in interviewing programmers who cannot program. Which he had posted about a couple of years ago. (I guess he was tweeting because the issue has not been resolved).

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”.

Jeff was responding to several other authors who had noted the same issue with finding qualified programmers.

When I was a student at Sheridan College, we had a great teacher named John.  John looked exactly like Gandolf the Grey;  if Gandolf was fond of the drink, smoked like a chimney and repeatedly told Frodo, “that’s a ‘you understood'”.  As luck would have it Lord of the Rings came out the year I was in John’s class so us students would constantly rib each other “YOU SHALL NOT PASS!”.  Good times.

One thing that became clear to me fairly quickly as a former teacher is that there is a basic level of understanding that we assume people have.  John’s ‘you understood’ was his way of stating he expected us to know that basic level of information.  His frustration however was people in the class who clearly did not understand.  I recall John’s lament that some students in his “C#” class couldn’t even turn on the computer without instructions.

One thing that became apparent in the class is that there is never “one solution”. The Fizzbuzz problem for example could be solved in a variety of ways, in a number of different languages and while the syntax would change the concepts would not.

Those basic concepts are the key to everything.

Programming consists of three structures, or rules.  I am sure if I was a ComSci student I would know the proper terms but I am an artist so just bear with me. The three structures are the loop, the decision and the step.

A loop is: repeat doing this step until this criteria is met.

A decision is:  If X is true then do this otherwise do that.

A step is : Do this, then do that.

Everything in life can be broken down into these component parts. Everything.  For example if you wanted to go to the store you would start with a decision, “Am I at the store?” if so then stop, go to store.  Walking is a loop, “While not at store, keep walking”.  It could even be broken down more, stand up then get keys, then lock door, then…and so on.

For the Fizzbuzz problem you need to run a loop that counts from 1 to 100.  Then you need to add decision statements that when a certain criteria is met something else happens.  That’s it, simple.

Programming isn’t about languages it’s about how you think.  Languages are merely syntax with which you express those thoughts.  Eloquent programming is how well you combine the two.

No votes yet.
Please wait...

One Comment

  1. That’s funny about John. If I recall, the “required” reading before we even starting the source was called “Programming Logic” I think… I think Margo wanted us to read Steven Covey’s 7 habits?

    Anyways, the programming logic was all about logic gates and stuff. I remember when he asked how many people had read it… there was a hush in the room! Thus started the tenure of an amazing professor, skinning of cats and “you understood’s!”

    LOL

    No votes yet.
    Please wait...

Comments are closed.