Simple sudoku solver written in Rust.
In the main file, you can build a board using the BoardBuilder. You can create the board like this:
fn main() {
let mut board = BoardBuilder::new()
.insert((0,0), 3)
.insert((0,4), 6)
.insert((3,5), 2)
.build(); // you must call the build function at the end of the building process.
if board.solve() {
println!("the board has been solved successfully!");
println!("{:?}", board)
} else {
println!("failed to solve the board :sad:")
}
}
or like this:
fn main() {
let mut board = BoardBuilder::from([
[3,0,0,0,6,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,2,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
]).build() // same here, you must call the build function.
if board.solve() {
println!("the board has been solved successfully!");
println!("{:?}", board)
} else {
println!("failed to solve the board :sad:")
}
}
both of them do the same exact thing, but in my opinion the first option is more handy.
You must have cargo installed. then in your shell, navigate to this project folder and run:
cargo run --release
this should compile and execute the program.
- add GUI and graphics.
- add option to load boards from a file.
- don't forget to complete the TODO list.