Commit Graph

1 Commits

Author SHA1 Message Date
ddidderr 06918ea670 feat: implement deductive Sudoku solver
Add a command-line Sudoku solver that reads a whitespace-separated puzzle file,
uses zeroes as empty cells, and prints a solved grid. The parser accepts any
square Sudoku size whose block shape is also square, including 9x9 with 3x3
blocks and 16x16 with 4x4 blocks.

The solver represents candidate sets as u128 bit masks and precomputes row,
column, block, and peer relationships for each cell. It repeatedly applies
human-style deterministic deductions by placing naked singles and hidden singles.
When those deductions stall, it falls back to a constrained trial search: choose
the unsolved cell with the fewest candidates, try high-impact values first, and
resume deduction after each assumption.

The public library API keeps parsing, solving, and formatting testable outside
the CLI. The README documents usage and the top-down project decomposition so
future changes have an architectural map.

Known limitation: the solver returns one valid completion for puzzles with
multiple solutions; it does not currently prove uniqueness.

Test Plan:
- cargo clippy
- cargo clippy --benches
- cargo clippy --tests
- cargo test
- cargo +nightly fmt
- cargo clippy
- cargo clippy --benches
- cargo clippy --tests
- cargo run -- /tmp/sudoku-ai-smoke.txt
- timeout 5 cargo run -- /tmp/sudoku-ai-underconstrained.txt

Refs: none
2026-04-25 20:57:44 +02:00