Sudoku

Number place · classic 9×9
Solved this year
GitHub
MonWedFri
Streak
0 days
Solved
0
Solve time
—

Rules

PuzzleTeam defines the rules as:

The rules of sudoku are simple:

1.You have to enter a numerical digit from 1 through 9 in each cell of a 9x9 grid made up of 3x3 regions, starting with various digits given in some cells.
2.Each row, column, and region must contain only one instance of each numeral.

Algorithm

How I actually solve one — the reasoning I run before any code does, written out in full. Read down the right column; the board on the left follows whichever step you are on.

6
5
5
3
8
7
2
9
6
3
1
5
9
2
1
6
8
3
4
7
8
9
1
7
4
3
9
2
5
8
1
5
4
8
6
4
5
2
9
Step 1 / 5
Step 1

Frame the grid as constraints

A Sudoku board is a grid carved into nine boxes, and every cell must end up holding a digit from 1 to 9. Before placing anything I size up the space, because the count of completed grids satisfying all three rules is known exactly:

Nothing enumerates a space like that, so I never treat the board as 81 independent choices. I treat it as 27 interlocking units — nine rows, nine columns, nine boxes — each of which must become a permutation of 1–9. Concretely, I keep one 9-bit mask per row, column, and box recording which digits that unit still needs, and every empty cell's candidate set is just the intersection of the three masks that cross it:

That frame is the whole engine. Placing a digit clears one bit from three masks, which shrinks the candidate sets of up to twenty peers at once — and on a daily puzzle, that shrinking is what solves the board, not search.

Test

The robotic solver on real boards: the daily puzzle comes straight from the API, and the samples — Basic up to Evil — replay recorded solver runs move by move.

Daily Puzzle
fetching the daily puzzle…
Solver trace
awaiting the solver service — the live trace and metrics land together with the API
Fills
—
Backtracks
—
Depth
—
Time
—