pub struct Sudoku { /* private fields */ }
Expand description
Contains an 81-size array of Option<u32>
.
Implementations
sourceimpl Sudoku
impl Sudoku
sourcepub fn try_insert(&self, loc: (usize, usize), num: u32) -> Result<Self, &str>
pub fn try_insert(&self, loc: (usize, usize), num: u32) -> Result<Self, &str>
Returns a Sudoku
that is the same as self
but with num
inserted at loc: (x, y)
(0-indexed) if it can be inserted there by sudoku rules.
sourcepub fn solution(&self, step: u64, quiet: bool) -> Option<Self>
pub fn solution(&self, step: u64, quiet: bool) -> Option<Self>
Returns the solved Sudoku
if it exists. If quiet
set to false, then prints each iteration while solving.
Examples
use newdoku::Sudoku;
let s = Sudoku::from_str(
"xxxxxxx9xx9x7xx21xxx4x9xxxxx1xxx8xxx7xx42xxx5xx8xxxx748x1xxxx4xxxxxxxxxxxx9613xxx",
);
assert_eq!(
s.solution(0, true).unwrap(),
Sudoku::from_str(
"157832496396745218284196753415378962763429185928561374831257649672984531549613827"
)
);
Trait Implementations
impl Copy for Sudoku
Auto Trait Implementations
impl RefUnwindSafe for Sudoku
impl Send for Sudoku
impl Sync for Sudoku
impl Unpin for Sudoku
impl UnwindSafe for Sudoku
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more