A comparison of solutions of a textbook problem

The problem

The functional solution

The logic solution

The functional logic solution