initArray: Create puzzle array

Description Usage Arguments Value Examples

Description

initArray takes a 9x9 matrix representation of a sudodu puzzle and creates a 9x9x9 logical array, which contains the information about which numbers can and cannot go in particular places based on the initial values in the puzzle.

Usage

1
initArray(puz)

Arguments

puz

a 9x9 matrix representation of a sudoku puzzle. Puzzle cells which do not contain a number should be coded as NA.

Value

Returns a 9x9x9 logical array which captures all information regarding which numbers can and cannot go in each cell of the sudoku puzzle. The dimensions of the array are represented by i, j, and k. The i and j dimensions correspond to the [i, j] cell of the 9x9 sudoku puzzle matrix, and the kth dimension represents the values of 1-9 which can possibly go into the cells of the sudoku puzzle.

The [i, j, ] elements of the array represent which values of 1-9 can possibly go into the [i, j] cell of the puzzle. If there is 1 TRUE and 8 FALSE then the kth element which is TRUE is the number that goes into the [i, j] cell of the sudoku puzzle. If there are 2 or more NAs in these 9 elements, then there is not enough information to fill in the cell.

The [i, , k] elements of the array represent where a particular value, k, can go in the ith row of the puzzle. Similar to above, if there is 1 TRUE and 8 FALSE then the jth element which is TRUE gives the [i, j] cell of the sudoku puzzle is the number k. If there are 2 or more NAs in these 9 elements, then there is not enough information to fill in the number k in the ith row.

The [, j, k] elements of the array represent where a particular value, k, can go in the jth column of the puzzle. Similar to above, if there is 1 TRUE and 8 FALSE then the ith element which is TRUE gives the [i, j] cell of the sudoku puzzle is the number k. If there are 2 or more NA's in these 9 elements, then there is not enough information to fill in the number k in the jth column.

Examples

1

JamesCuster/sudokusolvr documentation built on June 4, 2019, 7:46 a.m.