pub fn literal(values: &[usize]) -> Grid {
        // This makes me a little uncomfortable, but at least
        // it shouldn't be a problem for reasonable sizes.
        let size = (values.len() as f64).sqrt().ceil() as usize;
        assert_eq!(size*size, values.len());
        let mut grid = Grid::new(size);
        for ((_, dst_cell), &value) in grid.cells_mut().zip(values) {
            if value > 0 {
                for possibility in dst_cell.iter_mut() {
                    *possibility = false;
                }
                dst_cell[value-1] = true;
            }
        }
        grid
    }
/// Creates a new `Grid` from a slice representing initial conditions.
///
/// Primarily intended to ease setup of tests and examples, so it will panic if the slice isn't
/// setup properly. The slice must be a square where each element corresponds to a cell. A value
/// of `0` indicates that the cell is unconstrained/unknown.
///
/// # Examples
///
/// ```rust
/// # use rusudoku::grid::*;
/// let grid = Grid::literal(&[
///     1, 2, 3, 4,
///     3, 0, 0, 2,
///     2, 0, 0, 3,
///     4, 3, 2, 1,
/// ]);
/// assert_eq!(grid[CellId(4)], [false, false, true, false]);
/// assert_eq!(grid[CellId(5)], [true,  true,  true, true ]);
/// ```
Creates a new `Grid` from a slice representing initial conditions.
Primarily intended to ease setup of tests and examples, so it will panic if the slice isn't
setup properly. The slice must be a square where each element corresponds to a cell. A value
of `0` indicates that the cell is unconstrained/unknown.
Creates a new ` Grid ` from a slice representing initial conditions . Primarily intended to ease setup of tests and examples so it will panic if the slice isn ' t setup properly . The slice must be a square where each element corresponds to a cell . A value of ` 0 ` indicates that the cell is unconstrained / unknown .
pub fn literal(values: &[usize]) -> Grid {
        // This makes me a little uncomfortable, but at least
        // it shouldn't be a problem for reasonable sizes.
        let size = (values.len() as f64).sqrt().ceil() as usize;
        assert_eq!(size*size, values.len());
        let mut grid = Grid::new(size);
        for ((_, dst_cell), &value) in grid.cells_mut().zip(values) {
            if value > 0 {
                for possibility in dst_cell.iter_mut() {
                    *possibility = false;
                }
                dst_cell[value-1] = true;
            }
        }
        grid
    }
pub fn literal ( values : & [ usize ] ) -> Grid { // This makes me a little uncomfortable, but at least // it shouldn't be a problem for reasonable sizes. let size = ( values . len ( ) as f64 ) . sqrt ( ) . ceil ( ) as usize ; assert_eq ! ( size size values len ( ) ) ; let mut grid = Grid :: new ( size ) ; for ( ( _ , dst_cell ) , & value ) in grid . cells_mut ( ) . zip ( values ) { if value > 0 { for possibility in dst_cell . iter_mut ( ) { * possibility = false ; } dst_cell [ value - 1 ] = true ; } } grid }
Creates a new `Grid` from a slice representing initial conditions.
Creates a new ` Grid ` from a slice representing initial conditions .
values
&[usize]
values
&[usize]
examples
None
use rusudoku::grid::*;
None