Every puzzle in our Sudoku app is machine-generated, and every one of them makes two promises the player never sees: it has exactly one solution, and the difficulty label on it means something specific. Both promises are harder to keep than they sound. A grid that looks like a valid Sudoku can secretly have two answers; a puzzle with very few givens can be trivially easy; a puzzle stuffed with clues can still stump you. This post is the honest, first-hand version of how our generator actually works — the pipeline that fills a grid, carves it out, proves it unique, and then grades it by the reasoning it forces you to do rather than by any arithmetic you could run at a glance.
Why clue count is not difficulty
The single most persistent myth about Sudoku is that fewer givens means harder, and more givens means easier. It is intuitive and it is wrong. Difficulty is not about how much you are told; it is about what kind of thinking is required to get from what you are told to the answer. A puzzle can hand you thirty clues and still demand a chain of advanced deductions; another can give you twenty-four and fall over to nothing but “this cell is the only place a 7 can go in its box.” The count is a weak proxy at best, and a misleading one at worst.
There is a hard mathematical floor worth knowing: a classic 9×9 Sudoku with a unique solution needs at least 17 given cells — it was proven that no 16-clue puzzle can have a single answer. But 17 is a floor on uniqueness, not a ceiling on ease. Some 17-clue puzzles are approachable; plenty of 30-clue puzzles are brutal. So we do not grade by counting anything. We grade by solving — specifically, by watching which solving techniques a human would have to reach for, and how deep into that toolbox they have to go. That is the whole philosophy, and everything in the pipeline serves it.
The pipeline: fill, dig, verify, grade
Our generator runs four stages in a loop. First we build a completely solved grid. Then we remove numbers — “dig holes” — while continuously protecting the guarantee that only one solution survives. Then we hand the holey grid to a solver whose only job is to confirm the solution is unique. Finally we grade the puzzle by the techniques that solver needed, and if the grade does not match the difficulty we were asked to produce, we loop back and dig differently. The figure below is the shape of it.
Stage one: fill a complete valid grid
We start from a full, legal solution — all eighty-one cells filled, every row, column, and box holding one through nine exactly once. The workhorse here is backtracking: walk the cells in order, try a candidate value that does not clash with what is already placed, move on, and if you hit a cell with no legal candidate, unwind to the last decision and try the next option. To keep grids from looking samey, we seed the first box (or the diagonal boxes, which are independent of one another) with a shuffled set of digits before the backtracking fills the rest. The result is a fresh, fully solved board every time — the answer key the finished puzzle will eventually point back to.
Stage two: dig holes without breaking uniqueness
Now we take numbers away. Removing a given turns a solved grid into a puzzle, but every removal risks opening a second valid solution. The rule that governs this stage is simple to state and expensive to honour: a cell may be emptied only if the puzzle still has exactly one solution afterward. So digging is not a blind deletion pass; each candidate removal is provisional until the verifier (stage three) blesses it. If emptying a cell would create ambiguity, we put the number back and try a different cell.
How we choose which cells to try matters for the look of the puzzle as much as its logic. Many players expect a pleasing symmetry — the pattern of givens mirrored across the centre, or rotationally symmetric — so we can dig in symmetric pairs to preserve that aesthetic. Symmetry is a constraint we impose on ourselves; it makes digging harder and occasionally forces us to stop with a few more clues than a purely greedy dig would leave. That is a deliberate trade of minimalism for beauty, and it is one we make on purpose.
Stage three: verify the solution is unique
This is the promise-keeping stage, and it is why a Sudoku generator is really two programs wearing one coat: a generator and a solver. After each dig we run a solver that does not stop at the first answer it finds — it keeps searching for a second. If it finds two solutions, the removal is rejected. Only puzzles the solver can prove have a single answer ever reach a player.
Why does uniqueness matter so much? Because a genuine Sudoku is solvable by deduction, not by guessing. If a puzzle had two answers, there would be some point where pure logic runs out and you would have to flip a coin — and a puzzle that requires a coin flip is not a puzzle, it is a maze with two exits. Uniqueness is the property that guarantees there is always a next logical step, which is exactly the property our grader then measures.
Stage four: grade by the techniques it demands
Here is where we diverge from the clue-counting crowd. To grade a puzzle, we solve it a second time — but this time with a solver that mimics human reasoning rather than brute force. It applies solving techniques in ascending order of difficulty and records the hardest one it was forced to use:
- Naked and hidden singles — the gentlest logic: a cell with only one possible value, or a value with only one possible cell in its unit. A puzzle solvable with singles alone is our easiest tier.
- Naked and hidden pairs and triples — two or three cells in a unit that between them lock up two or three candidates, letting you eliminate those candidates elsewhere. This is the step into genuine intermediate play.
- Pointing and box/line interactions — when a candidate in a box is confined to one row or column, it can be struck from the rest of that line, and vice versa.
- Fish patterns such as X-Wing and Swordfish, and chain-based eliminations — the advanced tier, where you reason across the whole board about where a digit cannot be. These mark our hardest puzzles.
The grade is essentially “what is the most sophisticated tool you cannot avoid?” A puzzle that yields entirely to singles is Easy no matter how few clues it started with; a puzzle that forces an X-Wing is Hard no matter how many. That is how the same engine populates all six of our difficulty levels honestly: not by removing more numbers, but by digging until the technique ceiling lands where we want it. If a dig produces a puzzle that grades too gently for the level we asked for, we reject it and dig again — the loop-back arrow in the diagram above. The step-by-step hard-Sudoku walkthrough in our guides shows these same techniques from the solver’s seat.
How the variants change the rules
Our app ships eight variants — Classic, Mini, Killer, Irregular, X-Sudoku, Windoku, Even-Odd, and a 12×12 board — and each one bends the pipeline in a specific place. The shape of the loop stays the same; the constraints inside it change.
X-Sudoku adds two diagonals that must also contain one through nine. That is a new constraint the fill stage has to satisfy and the verifier has to honour, and it usefully changes the grading too: the diagonals give solvers extra deductions, so a grid that would be Hard as a classic can grade easier as an X-Sudoku, and a dig that respects the diagonals often reaches fewer clues. Windoku adds four extra shaded 3×3 regions that must each hold a full set, another overlay of constraints. Irregular replaces the nine tidy boxes with nine jigsaw-shaped regions, so the generator reasons about arbitrary regions instead of a fixed grid. Even-Odd marks cells that must hold an even or odd digit, pruning candidates before solving even begins.
Killer Sudoku is the biggest departure. It removes most or all starting givens and instead groups cells into cages, each labelled with a sum its cells must add to — with no repeats inside a cage. Now generation has to design the cages and their sums, uniqueness has to be verified against arithmetic as well as placement, and grading has to account for cage-based techniques (like the classic “45 rule” that a row, column, or box sums to 45) that simply do not exist in a classic grid. If you want the full tour of cages and sums, our Killer Sudoku rules and strategy guide covers it, and the broader variants explainer walks through how each mode differs.
The honest limits and trade-offs
No generator is free of compromises, and pretending otherwise would be exactly the kind of over-claiming this blog tries to avoid. Three trade-offs are worth naming.
Generation costs time. The verify step is the expensive one: proving uniqueness means running a solver to exhaustion, and we do it after candidate removals, potentially many times per puzzle. Pushing for the hardest tiers, or for symmetric layouts, means more rejected digs and more solver runs. This is why puzzle libraries tend to be generated ahead of time rather than the instant you tap “new game.”
Grading is a heuristic, not a universal truth. Difficulty is genuinely subjective — the technique you find obvious may be the one another player finds hard. Our tiers encode a defensible ordering of techniques, but the boundary between, say, a hard Medium and an easy Hard is a judgement call, and different reputable apps draw it in slightly different places. We tune the thresholds to feel right across a wide range of players; we do not claim a single objective difficulty number exists, because it does not.
Aesthetics fight minimalism. A symmetric clue pattern is prettier but usually leaves a few more givens than the leanest possible puzzle. Chasing the absolute minimum clue count would make uglier, less inviting boards. We favour a puzzle that looks good and grades honestly over one that hits a record-low clue count — another deliberate choice, not a limitation we are hiding.
If you want to feel the difference these choices make from the player’s side, the fastest route is simply to play a few across the difficulty ladder and notice that the “hard” ones are not the ones with the fewest numbers — they are the ones that make you think in a way the easy ones never did.
Notes
This is a first-hand account of the approach behind our own Sudoku generator, written to explain the concepts rather than to publish the internals. It deliberately avoids specific timings, clue-count targets per tier, and other benchmark numbers, because those are implementation details that shift as we tune the engine and stating a precise figure here would imply a stability we are not claiming. The technique names (naked and hidden singles, pairs and triples, pointing pairs, X-Wing, Swordfish, the Killer “45 rule”) are the standard vocabulary of Sudoku solving and are described in plain terms in our Sudoku glossary.
Sources
One external result is cited above rather than asserted from our own work:
- The 17-clue minimum — that no valid 16-clue classic Sudoku with a unique solution exists — is from Gary McGuire, Bastian Tugemann & Gilles Civario, “There is no 16-Clue Sudoku: Solving the Sudoku Minimum Number of Clues Problem via Hitting Set Enumeration” (2012).
Keep reading: all posts on the WizusLabs Engineering blog.