1 Stage 1

There are no wheats and chaffs for any of the stages of this assignment.

We will begin with a simplified version of the 24 Game, in which you have:
  • Numbers: 1 to 5. You have four cards of each number. Assume that the cards do not have suits on them, so there is no way to tell apart those of the same number.

  • Operations: addition and multiplication. You have three cards of each operation.

A configuration consists of seven cards, starting with a number and thereafter alternating operation and number. Thus, a configuration may look like 1 + 1 + 1 + 1.

The value of a configuration is the number we get by evaluating it, ignoring precedence rules and instead using right associativity. For instance,

1 + 2 * 3 + 4

would effectively be parenthesized as

1 + (2 * (3 + 4))

which evaluates to 1 + (2 * 7) = 1 + 14 = 15.

Problem: Write a program to determine how many different configurations have the value 24. Implement a function with the signatureThe 24-5-2 stands for “that combine to form 24 choosing from 5 different numbers and 2 different operators”.

how-many-24-5-2 :: () -> Number

that when applied to no inputs computes the number of these configurations.