about | help
CodingBat code practice

Code Help and Videos >

 FizzBuzz Practice Code

Video

Here is a little discussion and a series of live practice problems based of the famous FizzBuzz problem. FizzBuzz is a kind of famous introductory programming interview question. It's not deep or difficult; it just combines a little loop code with a little logic code. The idea is that someone with practice writing loop and logic code can write the solution out very quickly, so it makes a good first question to establish basic coding fluency. (See Constructive Advice below on this.)

FizzBuzz Problem Statement

So just for fun, here's a graduated series of problems that play on the same themes as FizzBuzz, working up to a slightly more complicated version of the FizzBuzz problem itself:

Basic logic:

Array structure:

Put it all together:

The FizzBuzz problem here is a little more complicated than the original, since we make you assemble the results in an array instead of just printing. We also specify arbitrary start and end numbers which enables a more interesting variety of tests.

Constructive Advice

Why is that someone with a lot of coding experience can just sit down and write FizzBuzz basically instantly? It's just practice. By the time you have written (and debugged!) hundreds of loops and hundreds of if-statements ... any new problem looks a bit like something you've solved before. There are not that many patterns.

The good news is, it's just practice! It's pretty quick to go through a bunch of CodingBat practice problems. I promise you, once you've solved 10 problems, the next 10 will go a lot faster. If you are feeling unsure of your coding ... just do the practice and be done with it.

Practice, practice, practice!

CodingBat.com code practice. Copyright 2013 Nick Parlante.