24 (puzzle)

The 24 puzzle is an arithmetical puzzle in which the objective is to find a way to manipulate four integers so that the end result is 24. For example, for the numbers 4, 7, 8, 8, a possible solution is $$(7-(8\div8))\times4=24$$.

The problem has been played as a card game in Shanghai since the 1960s, using playing cards. It has been known by other names, including Maths24. A proprietary version of the game has been created which extends the concept of the basic game to more complex mathematical operations.

Original version
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 first player that can achieve the number 24 exactly using only allowed operations (addition, subtraction, multiplication, division, and parentheses) wins the hand. Some advanced players allow exponentiation, roots, logarithms, and other operations.

For short games of 24, once a hand is won, the cards go to the player that won. If everyone gives up, the cards are shuffled back into the deck. The game ends when the deck is exhausted, and the player with the most cards wins.

Longer games of 24 proceed by first dealing the cards out to the players, each of whom contributes to each set of cards exposed. A player who solves a set takes its cards and replenishes their pile, after the fashion of War. Players are eliminated when they no longer have any cards.

A slightly different version includes the face cards, Jack, Queen, and King, giving them the values 11, 12, and 13, respectively.

In a variation of the game played with a standard 52-card deck, there are $$\tbinom {4+13-1}4=1820 $$ four-card combinations.

Expansion to more complex operations
Additional operations, such as square root and factorial, allow more possible solutions to the game. For instance, a set of 1,1,1,1 would be impossible to solve with only the five basic operations. However, with the use of factorials, it is possible to get 24 as $$(1+1+1+1)!=24$$.