pub struct Sudoku {
pub order: u8,
pub elements: Vec<Option<Element>>,
}
Expand description
A (partial) grid of elements.
Fields§
§order: u8
The order of this sudoku.
elements: Vec<Option<Element>>
The elements composing this sudoku.
Implementations§
Source§impl Sudoku
impl Sudoku
Sourcepub fn new(order: u8) -> Self
pub fn new(order: u8) -> Self
Constructs a new sudoku of the specified order.
This method reserves space in memory for the puzzle’s elements.
§Notes
This method does not generate a valid, uniquely solvable sudoku.
If you wish to generate such a sudoku (which you likely do), use
Sudoku::generate
.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Returns whether the puzzle is completely full of values.
Sourcepub fn groups(&self, pos: Point) -> [Group; 3]
pub fn groups(&self, pos: Point) -> [Group; 3]
Returns the relevant groups for checking a given element in the grid.
The number of groups is always equal to the number of dimensions plus one.
Sourcepub fn substitute(&self, index: Point, value: Option<Element>) -> Self
pub fn substitute(&self, index: Point, value: Option<Element>) -> Self
Places the specified value (or lack thereof) at the specified index, returning an owned copy.
Trait Implementations§
Source§impl Generate for Sudoku
impl Generate for Sudoku
Source§fn generate(order: u8, difficulty: Difficulty) -> Self
fn generate(order: u8, difficulty: Difficulty) -> Self
Generates a puzzle of the desired order and difficulty.
Source§impl Score for Sudoku
impl Score for Sudoku
Source§fn difficulty(&self) -> Option<Difficulty>
fn difficulty(&self) -> Option<Difficulty>
The graded difficulty score of this puzzle.
Source§impl Solve for Sudoku
impl Solve for Sudoku
Source§fn solution(&self) -> Result<Self, SolveError>
fn solution(&self) -> Result<Self, SolveError>
Returns the puzzle’s unique solution if it exists.
Source§fn is_uniquely_solvable(&self) -> bool
fn is_uniquely_solvable(&self) -> bool
Whether the puzzle has a unique solution.
impl StructuralPartialEq for Sudoku
Auto Trait Implementations§
impl Freeze for Sudoku
impl RefUnwindSafe for Sudoku
impl Send for Sudoku
impl Sync for Sudoku
impl Unpin for Sudoku
impl UnwindSafe for Sudoku
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more