While taking part in the
Global Day of Coderetreat,
one of the sessions had us implementing Conway's Game of Life without using
any "if" statements to force us to use polymorphism instead.
Anything that was an "if" in spirit, such as a switch statement or storing
functions in a dictionary, was also forbidden. For most of the code,
this was fairly straightforward, but the interesting problem was the code that
decided whether a cell lived or died based on how many neighbours it had:

Polymorphism allows different code to be executed depending on the type of
a value. In this particular case, we need to execute different code depending
on which value we have. It follows that each number has to have a different
type so we can give it different behaviour:

In the code that counts the number of neighbours, we use our new number
system by starting with Zero and incrementing when we find a
neighbour. To choose the next state of the cell, rather than inspecting the
number of neighbours, we ask the number of neighbours for the next state directly:

numberOfNeighbours.live_cell_next_generation()

And now we have no "if"s! It's possible to move the logic for choosing the
next cell out of the number classes, for instance using the visitor pattern,
which might feel a bit more natural. I suspect that reimplementing the natural
numbers is still going to feel about the same amount of crazy though.