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

Your feedback helps us improve.

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

About

Sudoku solving reduces to an exact cover problem. A valid puzzle has exactly one solution derivable through constraint propagation across 27 groups (9 rows, 9 columns, 9 boxes). Generating a proper puzzle requires removing clues from a completed grid while verifying uniqueness at each step. If uniqueness is not enforced, the puzzle is ambiguous and therefore broken. This tool uses a backtracking solver with MRV (Minimum Remaining Values) heuristic to both generate guaranteed-unique puzzles and solve any valid board in milliseconds.

Difficulty is controlled by the number of given clues: Easy provides 38 - 45 clues, Medium 30 - 37, Hard 25 - 29, and Expert 22 - 24. The minimum number of clues for a unique Sudoku is 17, proven by McGuire et al. in 2012. This tool does not go below 22 to keep generation fast. Pencil marks (candidates) are supported for advanced solving techniques. Note: the auto-solver assumes a valid puzzle. Feeding it a board with contradictions will correctly report no solution.

sudoku puzzle generator sudoku solver backtracking algorithm logic puzzle brain game number puzzle

Formulas

The backtracking solver operates on a constraint satisfaction model. For each empty cell, candidates are computed as:

Cr,c = {1,2,...,9} โˆ’ (Rr โˆช Colc โˆช Bb)

Where Cr,c is the candidate set for row r, column c. Rr is the set of values already in row r. Colc is the set of values in column c. Bb is the set of values in box b. The box index is computed as:

b = 3 โ‹… floor(r รท 3) + floor(c รท 3)

The MRV heuristic selects the empty cell with the smallest |Cr,c| (fewest candidates) to minimize branching. If |Cr,c| = 0 for any empty cell, the branch is pruned (backtrack). If |Cr,c| = 1, the value is forced (naked single). Puzzle generation removes clues symmetrically and verifies uniqueness by confirming the solver finds exactly 1 solution.

Reference Data

DifficultyGiven CluesAvg. Solve Time (Human)Techniques RequiredBacktrack Steps (Solver)
Easy38 - 4510 - 20 minNaked Singles< 50
Medium30 - 3720 - 40 minNaked & Hidden Singles50 - 200
Hard25 - 2940 - 90 minPairs, Pointing, Box/Line200 - 1000
Expert22 - 2460 - 180 minX-Wing, Swordfish, Chains1000+
Minimum Possible17Hours to DaysAll advanced + trial10000+
Constraint Groups
RowsEach row must contain digits 1 - 9 exactly once
ColumnsEach column must contain digits 1 - 9 exactly once
BoxesEach 3ร—3 box must contain digits 1 - 9 exactly once
Total Constraints27 groups ร— 9 values = 243 binary constraints
Sudoku Mathematics
Valid Completed Grids6,670,903,752,021,072,936,960 (Bertram Felgenhauer, 2005)
Essentially Different5,472,730,538 (after symmetry reduction)
Minimum Clue Puzzles49,151 known 17-clue puzzles catalogued
Search Space per CellUp to 9 candidates, reduced by constraints
Avg. Branching Factor2.5 - 4.0 for hard puzzles

Frequently Asked Questions

After removing each clue from a completed grid, the generator runs the backtracking solver in "counting" mode. If the solver finds more than one solution, that clue is restored and a different cell is tried. This process continues until the target number of clues is reached. The result is always a puzzle with a unique solution.
MRV (Minimum Remaining Values) selects the empty cell with the fewest legal candidates as the next cell to fill. This reduces the branching factor dramatically. A cell with 1 candidate needs no guessing. A cell with 2 candidates only branches twice. Without MRV, the solver might pick a cell with 7 candidates first, creating unnecessary branches that all eventually fail.
Yes. If the board has contradictions (e.g., two 5s in the same row), the solver detects this immediately and reports no solution. If the board is under-constrained (too few clues, multiple solutions), the solver finds the first valid solution. The "Validate" feature checks for conflicts in real time as you type.
Expert puzzles have only 22-24 clues. Removing that many cells while maintaining uniqueness requires more uniqueness checks. Each check runs a full solve. With fewer clues, more removal attempts are rejected because they create ambiguity. Generation typically takes 50-500 ms depending on the random seed.
Pencil marks (notes) are candidate annotations. They record which values you think are possible in a cell but haven't committed to. Toggle pencil mode with the pencil button or press P. Pencil marks do not count as placed values and are not checked for conflicts. They are a solving aid only.
The timer is purely informational. It tracks elapsed time from when the puzzle is generated or loaded. It pauses when you switch tabs (using the Page Visibility API). There is no scoring system. The timer helps you benchmark your improvement across sessions of the same difficulty level.