Skip to content

netfri25/sudoku-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple sudoku solver written in Rust.

Changing the board

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.

Running the code

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.

TODO:

  • add GUI and graphics.
  • add option to load boards from a file.
  • don't forget to complete the TODO list.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages