The countdown problem
In this chapter we show how Haskell can be used to solve the countdown problem, a numbers game in which the aim is to construct numeric expressions satisfying certain constraints. We start by formalising the rules of the problem in Haskell, and then present a simple but inefficient program that solves the problem, whose efficiency is then improved in two stages.
Countdown is a popular quiz programme that has been running on British television since 1982, and includes a numbers game that we shall refer to as the countdown problem. The essence of the problem is as follows:
Given a sequence of numbers ...