Struct Sudoku

Source
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

Source

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.

Source

pub fn is_complete(&self) -> bool

Returns whether the puzzle is completely full of values.

Source

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.

Source

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 Clone for Sudoku

Source§

fn clone(&self) -> Sudoku

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sudoku

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Sudoku

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FromStr for Sudoku

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Generate for Sudoku

Source§

fn generate(order: u8, difficulty: Difficulty) -> Self

Generates a puzzle of the desired order and difficulty.
Source§

impl Grid for Sudoku

Source§

fn points(&self) -> Vec<Point>

Returns all points in the grid. Read more
Source§

impl Index<Point> for Sudoku

Source§

type Output = Option<Element>

The returned type after indexing.
Source§

fn index(&self, index: Point) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl PartialEq for Sudoku

Source§

fn eq(&self, other: &Sudoku) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Puzzle for Sudoku

Source§

fn order(&self) -> u8

The order of the puzzle.
Source§

impl Score for Sudoku

Source§

fn score(&self) -> Option<usize>

The raw difficulty score of this puzzle.
Source§

fn difficulty(&self) -> Option<Difficulty>

The graded difficulty score of this puzzle.
Source§

impl Solve for Sudoku

Source§

fn solution(&self) -> Result<Self, SolveError>

Returns the puzzle’s unique solution if it exists.
Source§

fn is_uniquely_solvable(&self) -> bool

Whether the puzzle has a unique solution.
Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.