Skip to content
UniKit

24 point calculator

Takes four numbers and exhaustively enumerates every combination of + - x / with brackets to find expressions equal to 24, listing the solutions and their count. Only the four basic operations are used, division by zero is skipped and a 1e-9 tolerance means fractional solutions are found too.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Input

Result

A complete search over the four operations with brackets, listing the solutions found.

Enter four numbers to list every expression that makes 24.

Solutions: 0 · Numbers: 0

What this tool does

  • See how a stuck hand can be solved.
  • Check that a hand is solvable before setting it as a puzzle.
  • Demonstrate brackets and operator precedence.

Example

Input

6 6 6 6

Output

24 game solver (exhaustive over + − × ÷)
Input: 6  6  6  6

Found 4 solutions, the first 3 are listed below:
  ((6 × 6) − 6) − 6 = 24
  (6 + 6) + (6 + 6) = 24
  (6 × 6) − (6 + 6) = 24

First / shortest solution: ((6 × 6) − 6) − 6

Note: only + − × ÷ and brackets are used (no division by zero), with no factorials or powers;
the search covers every bracket structure with a 1e-9 tolerance, so fractional solutions such as 8 ÷ (3 − 8 ÷ 3) are found too.

Frequently asked questions

Only the four basic operations?

Yes: + - x / with brackets, no factorials, powers or roots, so hands like 1 1 1 1 really are unsolvable and the tool reports no-solution instead of inventing one.

How is the search done?

Pairwise merging: any two remaining numbers are combined in six ways (including reversed subtraction and division), producing a shorter list, recursing until one number remains. That is a complete search over bracket structures.

Why are there several solutions?

Different bracket forms can give the same value; results are de-duplicated by expression string, and "list every solution" shows up to 50.

Are fractional solutions found?

The arithmetic is double precision with a 1e-9 tolerance, so hands such as 3 3 8 8, solved as 8 / (3 - 8 / 3), are found.

Keywords:24 gamearithmetic puzzle

Related tools