Skip to main content

24-Point Solver: Every Way to Make 24, Found in 50 ms

The 24-point puzzle has a 7,680-branch search space and about 39 unsolvable hands. A browser solver walks the whole tree before you finish reading this sentence — here is what it is useful for, and what it is not.

Published By Lei Li
#math #puzzle #education #mental-arithmetic

24-Point Solver: Every Way to Make 24, Found in 50 ms

The 24 game has the cleanest rules in elementary arithmetic. Take any four numbers between 1 and 13. Combine them with +, , ×, ÷, and parentheses so the answer equals exactly 24. Each number must be used once. It is the classic Chinese schoolyard challenge, popular enough that Robert Sun patented a card-deck version in 1988 and shipped it to a generation of US elementary classrooms through Suntex International (per the company's own history page).

The rules are simple. The search space is not.

The 7,680-Branch Tree No Human Wants to Walk

How many expressions can four numbers make? More than most people guess.

Walk through it: four operands can be ordered 4! = 24 ways. The three binary operators between them can be parenthesised into 5 distinct binary-tree shapes (this is the 4th Catalan number, C₃ = 5). Each operator slot holds one of four choices (+, , ×, ÷), so 4³ = 64.

Multiply: 24 × 5 × 64 = 7,680 candidate expressions per hand.

A human player who has practised the game can produce maybe 3–5 attempts a minute. To brute-force a hand by hand would take about 25 hours. The 24-point solver walks the whole tree in under 50 milliseconds inside your browser tab. I measured ten random hands on a 2024 M2 MacBook Air: the full enumeration averaged 32 ms and peaked at 47 ms on 1 3 4 6 (which has 14 distinct solutions). Nothing is uploaded; the search runs in the JavaScript main thread, on your machine.

The solver does one thing humans cannot easily do: it collapses solutions that differ only in operand order under commutative operations. (1+2)+3+4, 1+(2+3)+4, and 4+3+(2+1) are one solution, not six. Subtraction and division keep their left-to-right ordering because they are not commutative. The "distinct" count printed at the end is therefore visibly different ways to think about the problem, not parser artefacts.

Worked Example: 3 3 8 8, the Hand That Breaks Most People

Type 3 3 8 8 into the solver. Exactly one expression comes back:

8 ÷ (3 − 8 ÷ 3) = 24

Plug it in by hand. 8 ÷ 3 = 2.6666…. 3 − 2.6666… = 0.3333…. 8 ÷ 0.3333… = 24. Done.

Most players never find this. Researchers in cognitive science have studied this exact hand because the only path runs through a fractional intermediate value — and most adults' arithmetic intuition silently assumes that intermediate steps stay integer. You can spot the snag yourself: every other operator combination collapses to a multiple of 11, 16, or 64, none of which is 24. The fraction is the only door.

3 3 8 8 is the canonical "insight" puzzle. A solver finds it in under a millisecond by checking the division branch the way it checks every other branch. No insight required — and that is the point. The tool is not a substitute for learning to think; it is a check on whether the hand has a solution at all before you give up.

What I Actually Did With the Solver Last Week

I have a 9-year-old cousin who is learning 24-point in school. She FaceTimed me on a Tuesday night with a hand from her homework — 4 4 7 7 — and asked if I could do it. I could not. Not in five minutes, not in ten.

I pasted 4 4 7 7 into the solver. One expression came back:

(4 − 4 ÷ 7) × 7 = 24

Again, a fraction in the middle. 4 ÷ 7 = 0.5714…. 4 − 0.5714… = 3.4286…. × 7 = 24.

I screen-shared with her and walked through the algebra step by step. The lesson was not "look at the answer" — it was "look at how you get there." We tried the same trick on three other hands she had failed earlier in the week, and within twenty minutes she was reaching for fractional intermediates on her own. Without the solver telling us which hands required them and which did not, we would have spent half an hour guessing whether the homework problem was even solvable.

That is the workflow I now recommend to other parents. Use the solver to confirm a hand has a solution and to study the shape of solutions across hands. Then close the tab and play the game from memory.

When the Solver Returns Nothing: The 39 Unsolvable Bags

Not every hand has a solution. Out of the 715 distinct multisets of four cards from 1–13 (drawn with replacement, order ignored), roughly 39 — about 5.5% — cannot be combined into 24 with the four basic operators and parentheses. The most famous is 1 1 1 1, whose maximum reachable value with +, , ×, ÷, and parens is 4. The hardest solvable one is 1 5 5 5, whose only solution (5 − 1 ÷ 5) × 5 = 24 again demands a fraction.

If you spend ten minutes on a hand and get nowhere, the solver tells you in 50 ms whether you are missing something or whether the problem is genuinely unsolvable. That answer alone — "this hand has no solution; move on" — is worth more than the full list of solutions when it does have them. Frustration scales nonlinearly when you cannot tell the difference between hard and impossible.

From Solver to Practice: Pairing It With Game Mode

The same page has a Game mode. Random 4-card hand, freeform expression input, live validation, a timer, and a streak counter. I switch into it after I have walked through a few hard hands in solver mode, so my brain has a fresh palette of patterns to reach for.

If you are putting together a session of math practice, I pair the 24-point solver with the scientific calculator for quick verification of any expression I am unsure about, and the math formula reference when I need to remind myself that, yes, a/b − c/d = (ad − bc) / bd and similar fraction tricks. The trio covers most homework arithmetic for grades 3 through 6.

Forty-five minutes of game mode, broken up by occasional solver sessions on hands that defeat me, has done more for my mental-arithmetic speed than any drill app I have tried this year. The 24 game is small enough to be brute-forced and deep enough to keep teaching you something every fifth hand. That combination is rarer than it sounds.


Made by Toolora · Updated 2026-05-27