KenKen Solver

Stuck on a KenKen? Draw its cages, type in the targets, and the solver fills the grid and tells you whether that answer is the only one. Reveal it one square at a time if you would rather keep going yourself. It also solves Calcudoku and MathDoku, and puzzles that hide the operations.

Built by Brian Hamilton

Grid size

Drag across squares to draw a cage, then give it a target.

Examples
Paste or copy the puzzle as text

Example line: A 12x. Use + - x / for the operations, ? when it is not shown, and just the number for a one-square cage.

Draw the cages, or pick an example, then press Solve.

Cage combination calculator

Every set of numbers a cage can hold.

How to use the solver, and the rules it follows

Fill an N×N grid with the numbers 1 to N so that no number repeats in a row or column, and the numbers in every cage make its target with its operation.

  • Draw a cage by dragging across squares (or tapping one square), then type the target and pick the operation. Tap a cage to change or delete it. Drawing over an existing cage replaces it.
  • − and ÷ on two squares mean the bigger number minus, or divided by, the smaller. On more squares, the biggest minus (or divided by) all the others, as some puzzle books use.
  • ? is for puzzles that show only the target: any of the four operations will do.
  • A one-square cage needs only its number.
  • Solve says whether the puzzle has one answer, more than one, or none, then lets you reveal one square at a time or the whole grid.
  • Copy link puts the puzzle in a link to share or come back to.

Enter the puzzle one cage at a time

Pick the grid size, then drag across the squares of a cage, or tap a single square, and type the number printed in its corner with its operation. Repeat until every square is in a cage; any square still shaded grey is not. Tap a cage to fix a typo or delete it. If the puzzle is in a newspaper or a book that leaves out the operations, use ? and the solver tries all four.

What each operation means to the solver, and how to type it in the text box.
OperationTypeThe cage's numbers must…
++add up to the target
×x or *multiply to the target
−-give the target when the smaller is taken from the bigger (on more squares: the biggest minus all the others)
÷/give the target when the bigger is divided by the smaller (on more squares: the biggest divided by all the others)
not shown?make the target with any of the four
one squarejust the numberbe that number

Start with the cages that have only one set of numbers

Every cage stands for a short list of number sets, and some lists have just one entry. Those are where a solver starts, and where you should too. In the 4×4 example, four of the eight cages can only be filled one way, up to the order of the two numbers:

Four cages with only one set of numbersThe 4 by 4 example with its eight cages. Four are shaded: 3+ in two squares can only be 1 and 2, 4× can only be 1 and 4, 7+ only 3 and 4, and 12× only 3 and 4. Each shaded square shows the two numbers its cage allows; the order inside each cage is not known yet.
3+ can only be 1 and 2, 4× only 1 and 4, and 7+ and 12× only 3 and 4. The order inside each cage comes later.

The top row then finishes two more cages. Its first two squares are the 1 and 2 of the 3+ cage, so the last two must be 3 and 4. The 2÷ cage can only be {1, 2} or {2, 4}, so it cannot hold the 3: its top square is 4 and the 2− cage's top square is 3. That leaves the 2− cage needing a 1 below its 3, and the 2÷ cage a 2 below its 4.

Row 1 settles two cagesThe same grid. The top row is shaded. Its first two squares hold 1 and 2 in some order, so the last two hold 3 and 4. The 2÷ cage can never hold a 3, so its top square is 4 and the 2− cage's top square is 3. Below them, the 2− cage needs 1 and the 2÷ cage needs 2.
Six squares settled without a single guess. The rest of the grid follows the same way: this puzzle never needs one.

On bigger grids more cages have a single set, and the products are the generous ones, because few pairs of numbers multiply to the same thing. In a 6×6, 11 of the two-square × targets have only one pair:

Two-square cages in a 6×6 that can only hold one pair of numbers. Two neighbouring squares always share a row or column, so the pair is always two different numbers.
OperationTarget = the only pair
+3 = 1,2 · 4 = 1,3 · 10 = 4,6 · 11 = 5,6
×2 = 1,2 · 3 = 1,3 · 4 = 1,4 · 5 = 1,5 · 8 = 2,4 · 10 = 2,5 · 15 = 3,5 · 18 = 3,6 · 20 = 4,5 · 24 = 4,6 · 30 = 5,6
−5 = 1,6
÷4 = 1,4 · 5 = 1,5 · 6 = 1,6

For any other cage, the cage combination calculator above lists every set. It can tell a bent cage from a straight one: three squares in an L can hold 1, 1 and 4 for 6+, because the two 1s sit in different rows and columns, but three squares in a line cannot.

One answer, two answers or none

The solver does not stop at the first grid it finds. It keeps looking for a second, and the verdict tells you what it found. One answer means no other grid fits every cage, so the puzzle is sound. More than one answer shades the squares that can go either way; a published KenKen has exactly one, so this nearly always means a cage was copied wrong. The Two answers example is the extreme case: three rows each marked 6+ in a 3×3 constrain nothing at all, and all 12 ways of filling a 3×3 with 1, 2 and 3 fit. No solution names the cage that cannot be made at all, when there is one.

The check is worth having for our own puzzles too. Building this solver showed that our KenKen game could deal a puzzle with two answers on its largest Hard settings, because its old check gave up after a fixed amount of work: 3 of 84 we sampled. It now checks every puzzle with this solver, and when a layout has two answers it turns a square where they differ into a one-square cage. Of 408 puzzles dealt since, across every size, operation mix and difficulty, all 408 have one answer.

Hiding the operations rarely matters

Some puzzles print only the targets and leave you to work out the operation. That sounds much harder, but it rarely makes a puzzle ambiguous: we took 180 puzzles from our game, 4×4 to 9×9 at every difficulty, hid all their operations, and 175 still had exactly one answer. Often the target itself rules out all but one operation: in two squares of a 6×6, 30 can only be 5×6, because no sum, difference or quotient of two numbers up to 6 gets that high, and 1 can only be a difference, because two different numbers never add, multiply or divide to 1.

How hard a puzzle is, from the solver's side

The solver reasons with two rules before it ever guesses: a cage keeps only the sets that still fit, and a number with one place left in a row or column goes there. On the same 180 puzzles from our game, those two rules alone finished every Easy puzzle, 57 of 60 Medium and 41 of 60 Hard. The rest needed a trial: try a number, follow it through, and back out if it breaks a cage. The Show one square button picks a square in one of the smallest cages still hidden, the kind you would usually crack first.

KenKen, Calcudoku and MathDoku

KenKen is a trademarked name, and the same puzzle is published as Calcudoku, MathDoku and KenDoku. It is generally credited to the Japanese teacher Tetsuya Miyamoto. The rules are the same under every name, so the solver works for all of them.

Play one, or try a cousin

Our free KenKen game deals puzzles from 3×3 to 9×9 with the operations and difficulty of your choice, every one checked for a single answer. Killer Sudoku uses sum cages on a sudoku grid, and Kakuro is all sums. The other solvers and best move calculators, from the Sokoban solver to Nim, are on the calculators page.