Add generator

This commit is contained in:
cool-mist
2025-01-04 22:30:46 +05:30
parent d6119de05a
commit 354b59c004
7 changed files with 310 additions and 1 deletions
+31 -1
View File
@@ -4,4 +4,34 @@ mod engine;
#[allow(unused)]
mod solver;
fn main() {}
#[allow(unused)]
mod generator;
use crate::generator::generator::generate;
use crate::solver::solver::Solver;
fn main() {
let start = std::time::Instant::now();
let board = generate();
let elapsed = start.elapsed();
println!("Generated a problem in {} ms", elapsed.as_millis());
let Some(board) = board else {
println!(
"Failed to generate a board after {} ms, Try again",
elapsed.as_millis()
);
return;
};
println!("{}", board.print());
let solutions = Solver::new(board).solve();
println!("Found {} solutions", solutions.len());
let solution = solutions.first().unwrap();
let mut idx = 0;
solution.iter().for_each(|m| {
idx += 1;
println!("{}. {}", idx, m.notation());
});
}