This is an implementation of a sudoku solver using the Crook's Algorithm
written in rust.
It can solve every level of sudoku puzzle.
It first attempts to solve without using guessing by using forced cells
and then applying preemptive sets
as per the paper.
If it cannot be solved and requires gussing, the puzzle is solved using backtracking
(commonly known as brute-forcing
).
To run it locally, run
git clone https://github.com/blood-rogue/sudoku_solver.git
cd sudoku_solver
cargo r -r
Then provide the entire board as one line.
Note: I used .
in the example for blanks but you can use any character other than 1
to 9
for blank spaces
It is tested on 5 levels with 100 challenges each
- easy
- medium
- hard
- expert
- evil
You can run all tests by running (You need to clone it first)
$ cargo test
Or can run the test individually for each difficulty by running
# Replace <difficulty> with one of the above levels
$ cargo test test_<difficulty>
You can find the test puzzles in the test/puzzles
directory.
- Damien Zhang's blog
Combination
fromitertools
crate modified to useIndexSet
as buffer
Note: The link to Damien's blog seems to be broken. web archive