# Fizz buzz

(Redirected from Bizz Buzz)

Fizz buzz is a group word game for children to teach them about division.[1] Players take turns to count incrementally, replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz".

## Play

Players generally sit in a circle. The player designated to go first says the number "1", and each player thenceforth counts one number in turn. However, any number divisible by three is replaced by the word fizz and any divisible by five by the word buzz. Numbers divisible by both become fizz buzz. A player who hesitates or makes a mistake is eliminated from the game.

For example, a typical round of fizz buzz would start as follows:

1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz, ...

## Variations

Different divisors can be used in place of, or in addition to, 3 and 5, and different words or gestures can replace "fizz" or "buzz". For example, in Australia a variant based on the game of cricket is played. In this variant, the special numbers are 4 and 6, which are replaced with the cricket umpiring gestures for their respective scoring plays. A common version of the game is also called "7 Boom". The players replace every number divisible by 7 or containing the digit 7 with "boom".[citation needed]

Instead of replacing numbers that have 3 or 5 as a factor, the game can be played by replacing numbers containing the digit 3 or 5 with "fizz" or "buzz".

1, 2, Fizz, 4, Buzz, 6, 7, 8, 9, 10, 11, 12, Fizz, 14, Buzz, 16, 17, 18, 19, 20, 21, 22, Fizz, 24, Buzz, 26, 27, 28, 29, Fizz, Fizz, Fizz, Fizz, Fizz, Fizz Buzz, Fizz, Fizz, Fizz, Fizz, 40, 41, 42, Fizz, 44, Buzz, ...

In these variations, sometimes only the actual digit is replaced, so 23 becomes "twenty-fizz" and 50 is "buzzty". This variation can be combined with the original to form an even more challenging sequence:

1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, Fizz, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, Fizz, Fizz, Buzz, 26, Fizz, 28, 29, Fizz Buzz, Fizz, Fizz, Fizz, Fizz, Fizz, Fizz Buzz, Fizz, Fizz, Fizz, Fizz, Buzz, 41, Fizz, Fizz, 44, Fizz Buzz, ...

The game can be played in a mathematical base other than 10. For example, playing in base 5 would proceed as follows:

1, 2, Fizz, 4, Buzz, Fizz, 12, 13, Fizz, Buzz, 21, Fizz, 23, 24, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz, ...

More challenging variation has the direction of play change on Fizz or Buzz, but not on Fizz-Buzz. For certain sequences, this makes the action bounce between 2 or 3 players and causes misplays when it breaks out. The 3/7 version of the game has a complex sequence between 12 and 18, for example. A New Jersey variation is just to say buzz on prime numbers and switch directions. The reversal of direction may be optional.

### Fizz Buzz Woof

One variation has expanded to such an extent as to have its own related name.[citation needed] Many of the above rules are the same. In this case, the number 3 becomes Fizz, 5 becomes Buzz, and 7 becomes Woof. The main rules in this game are that any number that contains the number or is divisible by that number is replaced by an occurrence of the word. If the number has 2 instances of that number (i.e. 33 or 55) and is divisible by that number, then the word is said three times in this example. The additional rule is that the words (if more than one occur) must be said in the order given in the title. For example:

1, 2, Fizz Fizz (3), 4, Buzz Buzz (5), Fizz (6), Woof Woof (7), 8, Fizz (9), Buzz (10), 11, Fizz (12), Fizz (13), Woof (14), Fizz Buzz Buzz (15), 16, Woof (17), Fizz (18), 19, Buzz (20), Fizz Woof (21), 22, Fizz (23), Fizz (24), Buzz Buzz (25), 26, Fizz Woof (27), Woof (28), 29, Fizz Fizz Buzz (30), Fizz (31), Fizz (32), Fizz Fizz Fizz (33), ...

Another variation is Fizz Buzz Pop Whack, where Pop replaces multiples of 7 and Whack replaces 11. Players can also make up onomatopoeic words for multiples of other numbers. Fizz Buzz Pop Whack Zing (8) Chop (13) is also popular.

## Other uses

### Programming interviews

Fizz buzz has been used as an interview screening device for computer programmers.[2][3] Creating a list of the first 100 Fizz buzz numbers is a trivial problem for any would-be computer programmer, so interviewers can easily sort out those with insufficient programming ability. The following code is an example implementation using JavaScript:

```// Initialize a string variable for the output
var output = '';

// Count to 100 using i as the counter
for (var i = 1; i <= 100; i++) {

// If i is not divisible by 3 or 5, append the number itself.
// Note: In JavaScript, non-zero integers are considered as
// truthy values, therefore if there's a remainder on both,
// we append the number instead.
if (i % 5 && i % 3) {
output += i + ' ';
}

// If i is divisible by 3 with no remainder, append Fizz
if (i % 3 === 0) {
output += 'Fizz ';
}

// If i is divisible by 5 with no remainder, append Buzz
if (i % 5 === 0) {
output += 'Buzz ';
}
}

// Print the output to the console
console.log(output);
```

A shorter version:

```var o='';
for (var i=1; i<=100; i++) {
i%3 || (o+='Fizz ');
i%5 || (o+='Buzz ');
!(i%3 && i%5) || (o+=(i+' '));
}
console.log(o);
```

F# version:

```let to_string i = match i%3, i%5 with
| 0,0 -> "FizzBuzz"
| 0,_ -> "Fizz"
| _,0 -> "Buzz"
| _ -> string i

for i in 1..100 do
printfn "%s" (to_string i)
```

A C++ template metaprogramming version:

```// Helper macros to make compiler output a bit more readable, but keep the
#define List _
#define Integer __

template <int Condition, typename A, typename B>
struct If;

template <typename A, typename B>
struct If<true, A, B> {
typedef A result;
};

template <typename A, typename B>
struct If<false, A, B> {
typedef B result;
};

struct Nil {};
struct Fizz {};
struct Buzz {};
struct FizzBuzz {};
template <int N>
struct Integer {
static const int value = N;
};

struct List {
typedef Rest rest;
};

template <typename Container, typename Value>
struct PushFront {
typedef List<Value, Container> result;
};

template <int N>
struct IntToFizzBuzz {
typedef typename If<
N % 15 == 0, FizzBuzz,
typename If<N % 3 == 0, Fizz, typename If<N % 5 == 0, Buzz, Integer<N>>::
result>::result>::result result;
};

template <int N>
struct DoFizzBuzz {
typedef typename PushFront<typename IntToFizzBuzz<N>::result,
typename DoFizzBuzz<N - 1>::result>::result result;
};

template <>
struct DoFizzBuzz<0> {
typedef Nil result;
};

template <typename T>
struct Print;

Print<DoFizzBuzz<100>::result> ___;

// Will print when attempting to compile with gcc 5.4:
// fizzbuzz.cc:61:32: error: aggregate ‘Print<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<_<Nil, __<1> >, __<2> >, Fizz>, __<4> >, Buzz>, Fizz>, __<7> >, __<8> >, Fizz>, Buzz>, __<11> >, Fizz>, __<13> >, __<14> >, FizzBuzz>, __<16> >, __<17> >, Fizz>, __<19> >, Buzz>, Fizz>, __<22> >, __<23> >, Fizz>, Buzz>, __<26> >, Fizz>, __<28> >, __<29> >, FizzBuzz>, __<31> >, __<32> >, Fizz>, __<34> >, Buzz>, Fizz>, __<37> >, __<38> >, Fizz>, Buzz>, __<41> >, Fizz>, __<43> >, __<44> >, FizzBuzz>, __<46> >, __<47> >, Fizz>, __<49> >, Buzz>, Fizz>, __<52> >, __<53> >, Fizz>, Buzz>, __<56> >, Fizz>, __<58> >, __<59> >, FizzBuzz>, __<61> >, __<62> >, Fizz>, __<64> >, Buzz>, Fizz>, __<67> >, __<68> >, Fizz>, Buzz>, __<71> >, Fizz>, __<73> >, __<74> >, FizzBuzz>, __<76> >, __<77> >, Fizz>, __<79> >, Buzz>, Fizz>, __<82> >, __<83> >, Fizz>, Buzz>, __<86> >, Fizz>, __<88> >, __<89> >, FizzBuzz>, __<91> >, __<92> >, Fizz>, __<94> >, Buzz>, Fizz>, __<97> >, __<98> >, Fizz>, Buzz> > ___’ has incomplete type and cannot be defined
//  Print<DoFizzBuzz<100>::result> ___;
//                                 ^
```

Here is FizzBuzzWoof written in Perl6

```my @numbers = (0..1000);
for @numbers -> \$x {
given \$x {
when \$x % 105 == 0 {
say "FizzBuzzWoof"
}
when \$x % 15 == 0 {
say "FizzBuzz"
}
when \$x % 21 == 0 {
say "FizzWoof"
}
when \$x % 35 == 0 {
say "BuzzWoof"
}
when \$x % 3 == 0 {
say "Fizz"
}
when \$x % 5 == 0 {
say "Buzz"
}
when \$x % 7 == 0 {
say "Woof"
}
default {
say \$x
}
}
}
```

## References

1. ^ Rees, Janet. Fizz Buzz: 101 Spoken Numeracy Games – Ideal for Mental Maths. Learning Development Aids. ISBN 978-1855033528.
2. ^ Using FizzBuzz to Find Developers who Grok Coding
3. ^ Coding Horror: Why Can't Programmers.. Program?