User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Category Puzzles
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

KenKen is a constraint-based arithmetic puzzle invented by Tetsuya Miyamoto in 2004. The grid must form a valid Latin Square: each row and column contains the digits 1 through n exactly once, where n is the grid dimension. Cells are grouped into cages, each marked with a target number and an arithmetic operation (+, โˆ’, ร—, รท). The digits within each cage must produce the target when combined using that operation. Incorrect cage arithmetic or a duplicate digit in any row or column constitutes an invalid solution. This generator constructs a guaranteed-unique-solution puzzle using backtracking Latin Square generation, randomized adjacency-based cage partitioning, and constraint-propagation verification.

Difficulty is controlled by cage size distribution and operation mix. Larger cages with multiplication increase combinatorial search space. Division and subtraction cages are restricted to two cells to ensure integer results. A 3ร—3 grid has 12 valid Latin Squares; a 9ร—9 grid has approximately 5.524ร—1027. The tool approximates puzzle difficulty assuming standard human solving heuristics. Pro tip: for classroom use, 4ร—4 Easy is appropriate for ages 7-9; 6ร—6 Hard suits adult solvers.

kenken puzzle generator math puzzle logic puzzle printable kenken latin square

Formulas

The puzzle enforces two constraint families simultaneously: the Latin Square constraint and the cage arithmetic constraint.

Latin Square Constraint:

For each row r: {ar,1, ar,2, โ€ฆ, ar,n} = {1, 2, โ€ฆ, n}

For each column c: {a1,c, a2,c, โ€ฆ, an,c} = {1, 2, โ€ฆ, n}

Cage Arithmetic Constraints:

Addition cage: โˆ‘ ai = T for all cells i โˆˆ cage

Subtraction cage (2 cells): |a1 โˆ’ a2| = T

Multiplication cage: โˆ ai = T for all cells i โˆˆ cage

Division cage (2 cells): max(a1, a2)min(a1, a2) = T , T โˆˆ Z+

Where n = grid dimension, T = cage target value, ai = digit in cell i. The generator first constructs a valid Latin Square via constrained random fill with backtracking, then partitions into cages using randomized BFS from seed cells, assigns operations based on difficulty parameters, and verifies solution uniqueness via constraint-propagation solver.

Reference Data

Grid SizeValid Latin SquaresTypical Cage CountEasy (Avg Cage Size)Hard (Avg Cage Size)Est. Solve Time (Easy)Est. Solve Time (Hard)
3ร—3124-51.52.01-2 min2-4 min
4ร—45765-81.82.53-5 min5-10 min
5ร—5161,2808-122.03.05-10 min10-20 min
6ร—6812,851,20010-162.23.28-15 min15-30 min
7ร—76.1ร—101314-202.33.512-20 min25-45 min
8ร—81.08ร—102018-262.43.515-30 min30-60 min
9ร—95.52ร—102722-322.53.820-40 min45-90 min
Operations Reference
+ AdditionSum of all digits in cage = target. Valid for cages of 2 - 5 cells.
โˆ’ SubtractionAbsolute difference of two digits = target. Restricted to 2-cell cages only.
ร— MultiplicationProduct of all digits in cage = target. Valid for cages of 2 - 4 cells.
รท DivisionRatio of larger to smaller digit = target (integer only). Restricted to 2-cell cages.
No operationSingle-cell cage. Target = the cell value (given digit).

Frequently Asked Questions

A 3ร—3 grid has only 12 valid Latin Squares, making generation trivial. At 9ร—9, the search space exceeds 5.5ร—1027 valid squares. The generator uses constrained random filling with backtracking, which remains fast (under 100ms) for grids up to 9ร—9 because it fills cell-by-cell while immediately pruning Latin Square violations.
Subtraction and division are binary operations. With three or more cells, the result depends on evaluation order, creating ambiguity. For example, cells containing 6, 3, 1 could yield 6โˆ’3โˆ’1 = 2 or 6โˆ’(3โˆ’1) = 4. KenKen convention eliminates this by limiting these operations to two-cell cages where the absolute difference or integer quotient is unambiguous.
Three factors: (1) average cage size - larger cages have more candidate combinations, requiring deeper search; (2) operation distribution - multiplication cages with large targets are harder than addition cages because factor enumeration is less intuitive; (3) proportion of single-cell (given) cages - Easy puzzles include more single-cell cages that act as anchors, reducing the search space. The Hard preset minimizes givens and maximizes multiplication and large-cage usage.
No. The generator includes a constraint-propagation solver that verifies uniqueness. If the initial cage partition produces an ambiguous puzzle, the algorithm adjusts cage boundaries or adds a single-cell cage to force uniqueness. Every puzzle output by this tool has exactly one valid solution.
The algorithm seeds random unvisited cells and performs a bounded BFS (breadth-first search) expansion to adjacent unvisited cells. The maximum expansion depth is controlled by the difficulty parameter: Easy caps at 2 - 3 cells per cage, Hard allows up to 4 - 5. Connectivity is guaranteed because BFS only visits orthogonally adjacent cells. After partitioning, each cage is validated for operation feasibility.
Yes. When assigning division to a two-cell cage, the generator checks whether max(a, b) รท min(a, b) yields an integer. If not, the operation falls back to subtraction, multiplication, or addition. This ensures all targets are positive integers.