The 24 Game is a very simple card game. Four cards are dealt at random, and the players must apply simple arithmetic operations to the four numbers on the cards; the goal is to obtain 24 as a result of these operations. Each of the four numbers must be used exactly once, and the available operations are addition, subtraction, multiplication, and division. For example, if the cards were (3, 1, 4, 1), a solution would be (1 + 1) * 3 * 4 = 24. In the simplest version of this game, we let A = 1, J = 11, Q = 12, K = 13, joker = 15. There are four cards of each normal denomination, and two jokers.

I was playing the 24 game on Friday night, and I claimed that fractions are not necessary in the 24 game; all problems in 24 that can be solved with fractions can also be done by division. After three examples to the contrary {(1, 5, 5, 5), (3, 3, 7, 7), (4, 4, 7, 7)}, I was forced to retract my claim. Fractions are indeed necessary to solve some hands of cards in 24. This leads to some interesting questions. First of all, how many hands require using fractions? How common is this type of hand?

To answer this question, I wrote a simple Python program to bash the 24 game. Admittedly, this program is terribly inefficient and a demonstration of bad coding style, but I think I’ve worked out the bugs. Given 3.5 minutes, my program can solve the 24 game entirely: It can generate every possible hand and give a solution for each (if a solution exists). The program can also determine if there exists a solution that does not require fractions.

Here’s a summary of the results of this program:

- There are 2366 possible hands.
- Out of these, 617 have no solution.
- An additional 23 require using fractions to solve.

So we see that around a quarter of all hands are unsolvable, while less than 1% of hands require fractions. Thus, in most cases, it’s not necessary to consider fractional solutions; my claim was based on empirical evidence and is true for most hands. Indeed, I suspect that most people would give up on these problems in 24 and claim that they are unsolvable; that may explain why I hadn’t ever seen a solution involving fractions until Friday night.

I’ll admit that this isn’t precisely correct; not all hands are equally likely to appear; (3, 3, 3, 3) would appear much less often than (3, 4, 5, 6), for example. However, I assume that averaged over a large number of hands, this ratio of hands is approximately accurate. Thus, averaged over all impossible hands, I assume that impossible hands occur with probability around .

Something that was discussed during Friday’s game was the idea of treating aces as 14 instead of 1. The rationale is that in most card games, aces are larger than kings. Under this new convention, what would be the probability of getting an impossible hand? My program computed 674 impossible hands, for an average impossibility rate of .

This doesn’t seem like a big difference, but note that most hands don’t contain aces. What if we only looked at the impossibility rate of hands that contain aces? Here, the difference is a bit larger. There are 559 hands that contain aces, and when we set aces as ones, the probability that a random hand *containing an ace* has no solution is , while the probability when we set aces as fourteens is . Therefore, from a practicality standpoint, more hands are solvable when we set aces as ones. The difference isn’t huge, however, so both conventions for aces are reasonable.

If you’re interested, here’s a complete list of hands that require fractions in their solutions. It’s amusing to solve these “hardest” problems in 24, though they become much easier when it is known a priori that they require fractions.

(1, 3, 4, 6)

(1, 4, 5, 6)

(1, 5, 5, 5)

(1, 6, 6, 8)

(1, 8, 12, 12)

(1, 10, 12, 15)

(2, 2, 13, 13)

(2, 2, 11, 11)

(2, 3, 5, 12)

(2, 4, 10, 10)

(2, 5, 5, 10)

(2, 6, 10, 15)

(2, 6, 15, 15)

(2, 7, 7, 10)

(2, 7, 12, 15)

(2, 8, 12, 15)

(2, 9, 10, 15)

(3, 3, 7, 7)

(3, 13, 13, 15)

(4, 4, 7, 7)

(4, 4, 6, 15)

(5, 5, 7, 11)

(5, 7, 7, 11)

## Recent Comments