[][src]Function sudokugen::solver::generator::generate

pub fn generate(base_size: usize) -> GenSudoku

Generate a new sudoku board with a unique solution.

The generate function creates a random board with a unique solution. It does this by "solving" the empty board using random guesses whenever it cannot find the correct solution. Once the empty board is solved, it iterates over each of the guesses and removes it if that guess is the only valid option for that cell.

use sudokugen::solver::generator::generate;

let puzzle = generate(3);

println!("{}", puzzle.board());
println!("{}", puzzle.solution());