[][src]Enum sudoku_backend::ops::BoardDifficulty

pub enum BoardDifficulty {
    Easy,
    Medium,
    Hard,
}

The difficulties sudoku boards can come in.

Consult doc/sudoku.md

Variants

Methods

impl BoardDifficulty
[src]

Calculate the score for a board according to doc/sudoku.md#scoring-formula

Negative duration is out of domain and will return None.

Examples

assert_eq!(BoardDifficulty::Easy.score(&Duration::seconds(120)), Some(55));
assert_eq!(BoardDifficulty::Hard.score(&Duration::seconds(250)), Some(126));

assert_eq!(BoardDifficulty::Medium.score(&Duration::seconds(-65)), None);

Parse a numerical representation of the difficulty.

Guaranteed to validly round-trip through to_numeric().

Examples

assert_eq!(BoardDifficulty::from_numeric(1), Some(BoardDifficulty::Easy));
assert_eq!(BoardDifficulty::from_numeric(2), Some(BoardDifficulty::Medium));
assert_eq!(BoardDifficulty::from_numeric(3), Some(BoardDifficulty::Hard));

assert_eq!(BoardDifficulty::from_numeric(0), None);
assert_eq!(BoardDifficulty::from_numeric(4), None);
assert_eq!(BoardDifficulty::from_numeric(25), None);

Convert difficulty to a numeric repr

Guaranteed to validly round-trip through from_numeric().

Examples

assert_eq!(BoardDifficulty::Easy.to_numeric(), 1);
assert_eq!(BoardDifficulty::Medium.to_numeric(), 2);
assert_eq!(BoardDifficulty::Hard.to_numeric(), 3);

assert_eq!(BoardDifficulty::from_numeric(BoardDifficulty::Easy.to_numeric()),
           Some(BoardDifficulty::Easy));

How many more squares to compensate difficulty with.

A good approximation of Sudoku difficulty is square sparsity, so to make a board easier one can simply add more squares to the default unique solution.

Examples

assert_eq!(BoardDifficulty::Easy.additional_squares(), 22);
assert_eq!(BoardDifficulty::Medium.additional_squares(), 11);
assert_eq!(BoardDifficulty::Hard.additional_squares(), 0);

Trait Implementations

impl PartialEq<BoardDifficulty> for BoardDifficulty
[src]

This method tests for !=.

impl Clone for BoardDifficulty
[src]

Performs copy-assignment from source. Read more

impl Copy for BoardDifficulty
[src]

impl Ord for BoardDifficulty
[src]

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Eq for BoardDifficulty
[src]

impl PartialOrd<BoardDifficulty> for BoardDifficulty
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Debug for BoardDifficulty
[src]

impl Hash for BoardDifficulty
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Serialize for BoardDifficulty
[src]

impl<'de> Deserialize<'de> for BoardDifficulty
[src]

impl<'v> FromFormValue<'v> for BoardDifficulty
[src]

The associated error which can be returned from parsing. It is a good idea to have the return type be or contain an &'v str so that the unparseable string can be examined after a bad parse. Read more

Returns a default value to be used when the form field does not exist. If this returns None, then the field is required. Otherwise, this should return Some(default_value). The default implementation simply returns None. Read more

Auto Trait Implementations

impl Send for BoardDifficulty

impl Sync for BoardDifficulty

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Typeable for T where
    T: Any
[src]

Get the TypeId of this object.

impl<T> IntoSql for T
[src]

Convert self to an expression for Diesel's query builder. Read more

Convert &self to an expression for Diesel's query builder. Read more