## Math24 Solver

Authors: Lydia Li, Emrys Yang

### What is the problem?

The Math24 Game is an arithmetical card game in which the objective is to find a way to manipulate four integers so that the end result is 24. For example, for the card with the numbers 4, 7, 8, 8, a possible solution is (7 - (8 / 8)) * 4 = 24. We will attempt to generate a Math 24 game of simple difficulty using Haskell and see if Haskell can solve it (generate all possible solutions). For more information of Math24, see here: 24 Game

### What is the something extra?

- We will attempt to see if we can implement a 5-number version of Math24. This will allow people to insert 5 numbers and our Solver will also give out expressions consist with these 5 numbers, and get sum 24.

```     Example: (6 + 7 + 5 + 2 + 4) = 24 and (3 + 4 + 6 + 6 + 5) = 24.
```

- We will attempt to see if we can create a simplified solution so that same solution with different number order will be eliminated.

```     Example: (6 + 7 + 5 + 6) = 24 and (7 + 6 + 6 + 5) = 24 will be regarded as the same solution.
```

- We will attempt to see if we can create higher levels of difficulties for Math24 and have Haskell solve it too:

```     The original version of 24 is played with an ordinary deck of playing cards with all the face cards removed. The aces are taken to have the value 1 and the basic game proceeds by having 4 cards dealt and the player that can achieve exactly number 24 using allowed operations wins this round of the game.
```

Normally when we play this game, we only using basic operations (addition, subtraction, multiplication, division, and parentheses) to keep it simple and time-saving. However, in our Math24 Solver, we would like to include face cards (Jack = 11, Queen = 12, King = 13) and using more complex operations:

• Exponentiation.
```     Example: for cards 4, 2, 5, 3, we can do calculations like (4^2 + 5 + 3) = 24.
```
• Square Root. (Due to prolog language expression, sqrt() is same as 2√, so card 2 is needed for this operation)
```     Example: for cards 4, 9, 2, 9, we can do calculations like (4 * (9 - sqrt(9))) = 24.
```
• Logarithms.
```     Example: for cards 4, 2, 10, 12, we can do calculations like (log2(4) + 10 + 12) = 24.
```
• Factorial.
```     Example: for cards 3, 2, 6, 6, we can do calculations like (3! + 2 *6 + 6) = 24.
```