24 Solver
Enter four numbers and instantly find every 24 game solution — no guessing, no button clicks required.
Enter Four Numbers (1–13)
What Is a 24 Solver?
A 24 solver is a tool that takes four numbers and exhaustively finds every arithmetic expression — using addition, subtraction, multiplication, and division — whose value equals exactly 24. It automates what players do mentally during the classic card game invented by Robert Sun in 1988.
In the original game, each player draws four cards from a standard deck (Ace through King, valued 1–13) and races to announce an equation first. A solver removes the time pressure and reveals all valid equations, making it ideal for classroom practice, competition prep, or simply satisfying curiosity.
How to Solve for 24: 3 Worked Examples
The fastest mental strategy for finding a math 24 game solution is to anchor on factor pairs, then work backwards.
Case 1 — 5, 6, 7, 8
Case 2 — 3, 7, 8, 9
Case 3 — 1, 5, 5, 5 (harder)
24 Game Solver Formula & Algorithm
Every twenty four game solver runs the same exhaustive search under the hood. Given four numbers (a, b, c, d), the algorithm:
- Generates all 4! = 24 permutations of the four numbers.
- For each permutation, places three operators from [+, −, ×, ÷] in all 4³ = 64 combinations.
- Evaluates all 5 distinct parenthesisation shapes (binary expression trees with 4 leaves).
- Checks whether any result equals 24 within floating-point tolerance (<10⁻⁹).
Because division can produce rational numbers, intermediate values are tracked as exact fractions to avoid rounding errors — the same technique used in competitive programming judge systems.
Why Some Cards Can't Make 24 — Tricky Combinations
Not every hand is solvable. The solver confirms this by exhausting all 7,680 expressions and finding none equal 24. Understanding tricky 24 math answers (or the lack thereof) sharpens your mental arithmetic.
- Impossible sets: roughly 1 in 14 four-card combinations has no solution (e.g., 1, 1, 1, 1 → max achievable is 4).
- Fraction traps: 3, 3, 8, 8 requires 8 ÷ (3 − 8 ÷ 3) = 24 — impossible to spot without allowing intermediate fractions.
- Negative intermediates: with 1, 5, 5, 5 the solution 5 × (5 − 1 / 5) = 24 passes through the fraction 1/5 as an intermediate step. The solver tests all branches including those with negative and fractional values.
- Single-solution hands: some combinations like 1, 2, 3, 4 have dozens of solutions; others like 1, 6, 6, 8 have exactly one — enter them to see.
A useful heuristic for the challenge 24 solver variant: if you see a 1 in your hand, try multiplying it by 24 or using it to shift a product by 1. If you see two identical numbers, consider (a ÷ a) = 1 as a building block.
The Backtracking Algorithm Behind Every 24 Card Game Solver
The 24 card game solver is a textbook application of recursive backtracking — the same technique used in Sudoku solvers, N-Queens, and chess engines. This connection makes it a favourite interview problem at companies like Google and Meta.
Pseudocode (recursive approach)
In engineering contexts, the same pattern appears in expression evaluators, compiler AST builders, and symbolic math systems. The key insight — reduce two operands to one result, then recurse — is a reusable primitive for any "combine items with operators" problem.
Unlike brute-force enumeration, the recursive approach prunes impossible branches early (e.g., division by zero) and naturally handles all tree structures without explicitly enumerating them as a separate step.