How Sudoku AI Works

A valid Sudoku puzzle has exactly one solution. That sounds like a simple constraint, but enforcing it while also generating puzzles quickly and at varying difficulty levels involves more complexity than it first appears.

The naive approach and why it fails

The simplest approach to Sudoku puzzle generation is to fill a grid completely, then remove numbers one at a time until you have a puzzle. After each removal, you check whether the remaining grid still has exactly one solution. If removing a number creates ambiguity, you put it back and try a different cell.

The problem is the uniqueness check. A naive uniqueness checker tries to solve the puzzle two ways and sees if it gets different results. But standard backtracking solvers can find solutions in multiple orders, and poorly written solvers can miss alternative solutions entirely. The result is puzzles that claim to be unique but aren’t.

How Sudoku AI handles it

Sudoku AI uses a dedicated solution counter — a backtracking algorithm designed to find all solutions up to a limit of two. If it finds exactly one, the puzzle is valid. If it finds two or more, it’s rejected. The counter is fast enough to run synchronously during puzzle generation without blocking the interface.

The generation process retries up to twenty times if it can’t produce a valid unique puzzle in a given attempt. In practice, it almost always succeeds on the first or second try. The retry ceiling is there as a safety net.

AI hints

The AI hint system works differently from the puzzle generator. When a player requests a hint, the current board state is sent to the Claude API. The model analyzes the board, identifies the most logical next move, and returns an explanation of the reasoning — not just the answer, but the technique being applied. This makes hints feel like getting help from a patient teacher rather than just having the answer revealed.

Mistake checking works locally: cells where the player’s entry doesn’t match the solution are highlighted in orange in real time. Undo is supported up to 30 steps, with keyboard shortcut support on desktop.

Try it

Sudoku AI is available at sudokuai.errabot.com on the web and on the Google Play Store for Android. New puzzles are generated fresh each session, so there’s always something new to solve.