← Blog

Why Generating Sudoku Puzzles Is Harder Than It Looks

July 5, 2026

Early in development, I built a rough validation pass: generate a batch of puzzles, hand-solve them, flag anything that felt wrong. That was the feedback loop — play the puzzle, describe what broke, iterate with the AI that wrote the generator.

Some puzzles stopped dead. I’d work through every obvious placement, eliminate candidates row by row, and eventually hit a wall. At first I assumed I was missing a technique. Eventually I realized the problem wasn’t me — it was the puzzle itself.

The generator had two failure modes. First: boards with no solution at all — the clues were contradictory, and no completed grid existed. Second: boards with multiple valid solutions — the clues were too sparse, so more than one completed grid satisfied all the constraints. When you land on a board like this mid-solve, you can make logically correct placements and still reach a dead end, because you happened to follow one branch of a forked solution space. Both feel identical from the outside: you’re stuck, and you can’t tell if it’s you or the puzzle.

I also tried using ChatGPT and Gemini to validate puzzles — even ChatGPT, which handled it better than Gemini, made invalid eliminations and skipped constraints. Generating Sudoku and solving Sudoku turned out to be very different problems. I had to build my own validator.

The fix for both failure modes is the same. After carving each clue from the filled grid, count solutions. Stop at two — if you find a second, the removal is invalid, the clue stays. This check is the slow part of generation, but not by much; the counter aborts the moment a second path appears.

Guaranteeing a unique solution was only the first problem. Fog introduced another.

What the fog hides

Standard Sudoku solving techniques assume you can see the entire board. X-Wings require finding a digit that appears in exactly two positions across two rows, then confirming that those positions share the same two columns. With most of the board under fog, that scan is impossible. You can’t check what you can’t see.

I learned this from a bug. The solver had X-Wing logic implemented and was running it against partially-fogged boards. What it was actually doing: eliminating candidates based on incomplete row and column data, producing wrong deductions that stalled the solver on Hard puzzles. The fix was to restrict advanced techniques to fully visible groups only — if any cell in a row or column is fogged, skip the technique for that group entirely.

Once that constraint was clear, the next question was obvious: could the server pre-generate genuinely hard puzzles and cache them? On a server you can run the generator as long as you want — produce an Expert puzzle with 59 empty cells, one that requires pairs and X-Wings to solve under normal conditions, then apply the fog and store the result.

I generated eight Expert puzzles, applied heavy fog, and ran the solver.

Zero solvable.

The fog was concealing the same cells that the hard techniques needed to see. In my testing, Expert puzzles stopped being reliably solvable once roughly five key cells were hidden. Server time changes nothing — this isn’t a performance problem.

That was the moment I understood Sudoku Fog. Fog doesn’t simply make Sudoku harder. It consumes the same information that advanced solving techniques depend on.

They compete for the same resource.

The puzzle that shipped broken

In late June I played a daily puzzle and couldn’t solve it. I worked through the visible cells, tried every deduction I could see, came up empty. Assumed I was missing something and came back to it. Same result.

The generation code had a fallback: try three fog patterns, ship whichever is best. If none of the three produced a solvable board, it shipped the last attempt anyway. No validation gate on the way out.

Two consecutive daily puzzles — June 22 and June 23 — went out that way. I knew immediately that these were the same feeling as the early validation failures, except now it was a shipped product. The fix was to require the solvability check to pass on every single clue removal during carving, and to run up to 36 generation attempts before admitting failure. The unconditional fallback is gone.

Players should never have to wonder whether the puzzle is broken. If they get stuck now, I want it to be because they missed something — not because I did.


Sudoku Fog is free to play in your browser — no install required.