Struct sudokugen::solver::generator::Puzzle[][src]

pub struct Puzzle { /* fields omitted */ }

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,