Struct sudoku::Sudoku [] [src]

pub struct Sudoku(_);

The main structure exposing all the functionality of the library Sudokus can be parsed in either the line format or the block format

line format:

..3.2.6..9..3.5..1..18.64....81.29..7.......8..67.82....26.95..8..2.3..9..5.1.3.. optional comment

block format:

__3_2_6__ optional comment
9__3_5__1 another comment
__18_64__
__81_29__
7_______8
__67_82__
__26_95__
8__2_3__9
__5_1_3__

alternatively also with field delimiters

__3|_2_|6__ optional comment
9__|3_5|__1 another comment
__1|8_6|4__
---+---+--- comment: "-----------", i.e. '-' 11 times is also allowed
__8|1_2|9__          but has to be consistent
7__|___|__8
__6|7_8|2__
---+---+---
__2|6_9|5__
8__|2_3|__9
__5|_1_|3__

'_', '.' and '0' are accepted interchangeably as unfilled cells

Methods

impl Sudoku
[src]

[src]

Generate a random, solved sudoku Any valid sudoku can occur with equal probability

[src]

Generate a random, uniquely solvable sudoku The puzzles are minimal in that no cell can be removed without losing uniquess of solution Most puzzles generated by this are easy

[src]

Creates a sudoku from a byte slice. All numbers must be below 10. Empty cells are denoted by 0, clues by the numbers 1-9. The slice must be of length 81.

[src]

Creates a sudoku from a byte array. All numbers must be below 10. Empty cells are denoted by 0, clues by the numbers 1-9.

[src]

Reads a sudoku in the line format Stops parsing after the first sudoku

[src]

Reads a sudoku in the block format with or without field delimiters Stops parsing after the first sudoku

[src]

Reads a sudoku in a variety of block formats, applying few constraints. '_', '.' and '0' are treated as empty cells. '1' to '9' as clues. Each line needs to have 9 valid cells. Lines that don't contain 9 valid entries are ignored. Stops parsing after the first sudoku. Due to the lax format rules, the only failure that can occur is that there are not enough rows.

[src]

Try to find a solution to the sudoku and fill it in. Return true if a solution was found. This is a convenience interface. Use one of the other solver methods for better error handling

[src]

Find a solution to the sudoku. If multiple solutions exist, it will not find them and just stop at the first. Return None if no solution exists.

[src]

Solve sudoku and return solution if solution is unique.

[src]

Counts number of solutions to sudoku up to limit This solves the sudoku but does not return the solutions which allows for slightly faster execution.

[src]

Checks whether sudoku has one and only one solution. This solves the sudoku but does not return the solution which allows for slightly faster execution.

[src]

Solve sudoku and return the first limit solutions it finds. If less solutions exist, return only those. Return None if no solution exists. No specific ordering of solutions is promised. It can change across versions.

[src]

Check whether the sudoku is solved.

[src]

Returns an Iterator over sudoku, going from left to right, top to bottom

[src]

Returns a byte array for the sudoku. Empty cells are denoted by 0, clues by the numbers 1-9.

[src]

Returns a representation of the sudoku in line format that can be printed and which derefs into a &str

use sudoku::Sudoku;

let mut grid = [0; 81];
grid[3] = 5;
let sudoku = Sudoku::from_bytes(grid).unwrap();
let line = sudoku.to_str_line(); // :SudokuLine
println!("{}", line);

let line_str: &str = &line;
assert_eq!(
    "...5.............................................................................",
    line_str
);

Trait Implementations

impl Copy for Sudoku
[src]

impl Clone for Sudoku
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for Sudoku
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl PartialOrd for Sudoku
[src]

The ordering is lexicographical in the cells of the sudoku going from left to right, top to bottom

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

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

1.0.0
[src]

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

1.0.0
[src]

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

1.0.0
[src]

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

impl Ord for Sudoku
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl Hash for Sudoku
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

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

impl Eq for Sudoku
[src]

impl Debug for Sudoku
[src]

[src]

Formats the value using the given formatter.

impl Display for Sudoku
[src]

[src]

Formats the value using the given formatter. Read more