Reducer

Struct Reducer 

Source
pub struct Reducer<S: Solver, R: Rng> { /* private fields */ }
Expand description

A reducer can be applied to the output of a Generator to remove numbers from the grid as long as it is still uniquely solveable using the provided Solver. This may be intentionally suboptimal to control the difficulty. A random number generator decides which digits are removed.

Reducer::new_default will yield a reducer with the highest difficulty (a perfect backtracking solver) and a ThreadRng.

Implementations§

Source§

impl Reducer<BacktrackingSolver, ThreadRng>

Source

pub fn new_default() -> Reducer<BacktrackingSolver, ThreadRng>

Generates a new reducer with a BacktrackingSolver to check unique solveability and a ThreadRng to decide which digits are removed.

Source§

impl<S: Solver, R: Rng> Reducer<S, R>

Source

pub fn new(solver: S, rng: R) -> Reducer<S, R>

Creates a new reducer with the given solver and random number gnerator.

§Arguments
  • solver: A Solver to be used to check whether a reduced Sudoku is still uniquely solveable. This controls the difficulty by specifying a strategy that must be able to solve the Sudoku.
  • rng: A random number generator that decides which digits are removed.
Source

pub fn reduce<C: Constraint + Clone>(&mut self, sudoku: &mut Sudoku<C>)

Reduces the given Sudoku as much as possible. That is, removes random digits until all remaining ones are necessary for the solver used by this reducer to still be able to solve the Sudoku. All changes are done to the given mutable Sudoku.

Auto Trait Implementations§

§

impl<S, R> Freeze for Reducer<S, R>
where S: Freeze, R: Freeze,

§

impl<S, R> RefUnwindSafe for Reducer<S, R>

§

impl<S, R> Send for Reducer<S, R>
where S: Send, R: Send,

§

impl<S, R> Sync for Reducer<S, R>
where S: Sync, R: Sync,

§

impl<S, R> Unpin for Reducer<S, R>
where S: Unpin, R: Unpin,

§

impl<S, R> UnwindSafe for Reducer<S, R>
where S: UnwindSafe, R: UnwindSafe,

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