The drinking game that taught me to code

Say buzz! (For every number divisible by five)

Before last week I thought fizzbuzz was just a drinking game.

You go around the circle each saying a number, counting up to 100.

But if the number is divisible by three, you say fizz.

If the number is divisible by five, you say buzz.

And if the number is divisible by three and five you say fizzbuzz.

If you get it wrong, you drink two fingers worth of your drink.

You don’t reach 100.

I don’t think we ever reached 50.

But it turns out, thanks to my brother, a developer, it’s also a really cool way of learning to code.

Fizzbuzzing with my brother

Why sit round in a circle getting drunk if you can get a computer to play the game for you?

So now, as well as hoping to get my computer to do all my work for me, I’m going to get it to have all my fun as well.

This wasn’t the plan.

But the game was genuinley enjoyable. That may have been because I was playing it with my big bro, though.

It also helped some potential of coding click in my head. I could get this computer to say a number or say fizz when that number is divisible by three, or say buzz when it’s divisible by five or say fizzbuzz when it is divisible by 3 or five.

This helped me understand a concept called branching.

In ruby the computer understands these orders when you use terms like if, elsif and else.

If you are interested in trying this out then you will need a text editor (although you can use notepad if you don’t want all the pretty colours).

I recommend Visual Studio Code. It’s very pretty and unlike Sublime Text (recommended by Chris Pine in the book I mentioned in the last blog post) doesn’t say you can use the free version and then ask you to register all the time.

You can also save your code in a public space. Github is the place developers hang out, so you could get a profile. Here’s mine. My brother watched me put my real name, my real photo and then I saw his name and it was something IloveUnicorns78 and a picture of a robot. Not Cool. Anyway, I’m outed and a learner-coder now.

And, I’m starting to learn that developers are pretty friendly people. So if you are a developer and want to look at my code for fizzbuzz and tell me how I could improve, here it is.

Like what you read? Give Clare Spencer a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.