pub struct Grid {
pub empty_cell_count: usize,
pub solved: bool,
/* private fields */
}
Expand description
Struct to represent a Sudoku grid, with fields for the representation as rows, columns and boxes, as well as the candidate matrix, an empty cell count field, and a boolean representing whether the puzzle has been solved.
Fields§
§empty_cell_count: usize
§solved: bool
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn candidate_matrix(&self) -> &CandidateMatrix
pub fn candidate_matrix(&self) -> &CandidateMatrix
Return a reference to the candidate_matrix
field.
Sourcepub fn clear(&mut self, cell: Coord) -> Result<(), GridError>
pub fn clear(&mut self, cell: Coord) -> Result<(), GridError>
Set cell
to empty. Returns an error if called on a clue.
Sourcepub fn update(&mut self, cell: Coord, val: u8) -> Result<(), GridError>
pub fn update(&mut self, cell: Coord, val: u8) -> Result<(), GridError>
Update the value at cell
to val
. Returns an error if cell
is a
clue, or the update would result in another cell having zero valid
candidates.
Sourcepub fn remove_candidate(&mut self, cell: Coord, val: u8) -> bool
pub fn remove_candidate(&mut self, cell: Coord, val: u8) -> bool
Remove candidate val
from the set at cell
.
Sourcepub fn get_min_candidates_cell(&self) -> Coord
pub fn get_min_candidates_cell(&self) -> Coord
Returns the coordinates of the cell with the least valid candidates.
Sourcepub fn set_clues(&mut self)
pub fn set_clues(&mut self)
Set all Filled
cells to Clue
s of the same value. Used in puzzle
generation.
pub fn reset_candidate_matrix(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Grid
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnwindSafe for Grid
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