Struct sudokugen::solver::generator::Puzzle [−][src]
This structure represents a generated board and its solution
This struct can only be created by calling the generate
function, which will create
a random board with a unique solution.
Implementations
impl Puzzle
[src]
pub fn generate(board_size: BoardSize) -> Puzzle
[src]
Generate a new sudoku puzzle 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::{Puzzle, BoardSize}; let puzzle = Puzzle::generate(BoardSize::NineByNine); println!("{}", puzzle.board()); println!("{}", puzzle.solution());
pub fn board(&self) -> &Board
[src]
Returns the minimal board generated
use sudokugen::{Puzzle, BoardSize}; let gen = Puzzle::generate(BoardSize::NineByNine); println!("{}", gen.board());
pub fn solution(&self) -> &Board
[src]
Returns the solution for the generated board
use sudokugen::{Puzzle, BoardSize}; let gen = Puzzle::generate(BoardSize::NineByNine); println!("{}", gen.solution());
pub fn is_solution_unique(&self) -> bool
[src]
Verify that the solution for the generated board is unique.
use sudokugen::{Puzzle, BoardSize}; let gen = Puzzle::generate(BoardSize::NineByNine); assert!(gen.is_solution_unique());
Auto Trait Implementations
impl RefUnwindSafe for Puzzle
impl Send for Puzzle
impl Sync for Puzzle
impl Unpin for Puzzle
impl UnwindSafe for Puzzle
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,