MICHA.ELMUELLER

 

FizzBuzz with Computer Science Undergraduates

During the semester break I was involved in the redesign of a computer science lecture for undergraduates (mostly in their second semester). The lecture is centered around programming topics, such as patterns or object-oriented programming and builds upon the lecture “Introduction to Computer Science”, which teaches basic programming skills in Java (amongst other stuff).

In the week before the semester started, the idea of conducting the FizzBuzz test with the undergraduates came along. FizzBuzz seems to be a popular game in schools within the UK and has gained infamous popularity, since some people started to use it during job interviews as a test for developers. The task seems to be quite simple, but more people than you might think do not get it right, when having to write it down on paper without any debugging utilities.

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

Now you might think “Pfffhh! I can do that!”. Well, you might want to try that out before reading on. So, we decided to conduct this test with the undergraduates in the mentioned course. The goal was to gather a better understanding of their problems and common mistakes. They were required to program the test in Java. The FizzBuzz test was the second task of the quiz, the first consisted of writing a simple class with a constructor and creating an instance of it. The quizz was not rated, the purpose was just to gather a better understanding of the students previous knowledge and problems.

I quickly want to highlight the most interesting results concerning FizzBuzz: of the 176 participants 28 students (16%) made no mistake at all. Leaving minor errors (syntax, type, assignment, etc.) out, five more students (19%) got the task right. 40 submissions (23%) had so much stuff missing, that they couldn’t be rated. Of the 33 students who got the task right (not taking minor errors into account), 21 reported having some programming experience before starting to study.

21 students (12%) made an off-by-one error similar to this: for (int i = 1; i < 100; i++) { ... }.
81 students (46%) made logical errors, along the lines of composing the if-conditions wrongfully. Wrongful code like this was very common (pseudo-code intended):

if (i % 3 == 0) print("Fizz")
else if (i % 5 == 0) print("Buzz")
else if (i % 3 == 0 && i % 5 == 0) print("FizzBuzz")
else print(i)

Note that the third if-condition will never get invoked. One reason for writing down the if-conditions in this order might be that the exercise text described the cases in this order. It seems to me, that the most failure-prone (but also most obvious) approach to the task might be to directly translate the exercise description into code.

The results of this quiz were discussed with the students in the second lecture.

Category: Unilife

Tagged: ,

Write a comment

About Me

I am a 29 year old techno-creative enthusiast who lives and works in Berlin. In a previous life I studied computer science (more specifically Media Informatics) at the Ulm University in Germany.

I care about exploring ideas and developing new things. I like creating great stuff that I am passionate about.

License

All content is licensed under CC-BY 4.0 International (if not explicitly noted otherwise).
 
I would be happy to hear if my work gets used! Just drop me a mail.
 
The CC license above applies to all content on this site created by me. It does not apply to linked and sourced material.
 
http://www.mymailproject.de