<< Algorithms Algorithms sudoku_candidateprint >>

Sudoku Toolbox >> Algorithms > sudoku_candidatefind

sudoku_candidatefind

Find a candidate in the sudoku.

Calling Sequence

[rows,cols] = sudoku_candidatefind ( X , C , L , d )

Parameters

X:

a 9-by-9 matrix, with 0 for unknown entries

C:

a 9 x 9 cell of candidates

L:

the 9 x 9 matrix of number candidates

d:

the digit to find in the sudoku

rows:

the rows where the candidate is found

cols:

the columns where the candidate is found

Description

Search for the candidate d in all the nonfixed cells of the sudoku X. The number of cells where d is a candidate is size(rows,"*") = size(cols,"*"). The loop of the the nonfixed cells which contain d as a candidate is made by for k = 1 : size(rows,"*") then with r = rows(k) and c = cols(k).

The search is performed column by column, which implies the ordering of the result: the cols array is sorted in increasing order.

Examples

X = [
4 0 0   3 9 0   0 0 2
2 6 0   0 5 8   3 9 0
5 9 3   6 0 0   1 8 0
..
1 0 0   8 6 0   0 0 9
6 0 5   9 0 0   2 0 0
0 3 9   2 4 5   0 1 6
..
0 5 6   0 0 9   0 2 0
0 1 4   7 0 0   9 0 5
9 0 0   5 3 0   0 0 0
];
[C,L] = sudoku_candidates(X);
[rows,cols] = sudoku_candidatefind ( X , C , L , 2 );

Authors

<< Algorithms Algorithms sudoku_candidateprint >>