A functional programming version of Gabriele Cirulli's addictive little game