Activity: Fizzbuzz
A deep dive into the classic programming interview question

EXERCISE: FIZZBUZZ

Requirements

  • Write a program that prints the numbers from 1 to 100, with the following exceptions:

    • For multiples of three print "Fizz!" instead of the number.

    • For multiples of five print "Buzz!" instead of the number.

    • ​For numbers which are multiples of both three and five print "FizzBuzz!".

WHEN YOU'RE DONE....

Expansions on FizzBuzz

    • Watch Tom Scott's take on Fizzbuzz while you wait for others to finish up. Consider how the problem can be expanded and the code can be improved.


LET'S DISCUSS

Analysis

  • Share your solutions with the class

  • Consider pros and cons of each solution

  • What makes something good style?

  • Idea of overhead - costs and benefits of optimal implementations