Struct SudokuBoard

Source
pub struct SudokuBoard {
    pub cells: [[Cell; 9]; 9],
}

Fields§

§cells: [[Cell; 9]; 9]

Implementations§

Source§

impl SudokuBoard

Source

pub fn new() -> Self

Create an empty board with all cells “locked”

Source

pub fn fill(&mut self)

Fill board completely with solved state

Source

pub fn unused_in_box( grid: [[Cell; 9]; 9], row_start: usize, col_start: usize, num: u8, ) -> bool

Returns false if given SRN x SRN block contains num.

Source

pub fn check_if_safe(grid: [[Cell; 9]; 9], i: usize, j: usize, num: u8) -> bool

Check if safe to put in cell

Source

pub fn unused_in_row(grid: [[Cell; 9]; 9], i: usize, num: u8) -> bool

Source

pub fn unused_in_col(grid: [[Cell; 9]; 9], j: usize, num: u8) -> bool

Source

pub fn fill_remaining(&mut self, i: usize, j: usize) -> bool

A recursive function to fill remaining matrix

Source

pub fn solve(grid: [[Cell; 9]; 9], counter: u32) -> u32

Get the amount of unique solutions a board has

Source

pub fn check_valid(grid: [[Cell; 9]; 9]) -> bool

Check if the board has no mistakes

Source

pub fn check_solved(grid: [[Cell; 9]; 9]) -> bool

Check if the board is solved

Source

pub fn check_filled(grid: [[Cell; 9]; 9]) -> bool

Check if the board is completely filled

Source

pub fn remove_cells(&mut self, attempts: u32)

Remove cells from the filled solved board to make a puzzle

Source

pub fn display(&self)

Display the board in stdout

Source

pub fn display_grid(grid: &[[Cell; 9]; 9])

Display grid in stdout

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V