<< sudoku_issolved Algorithms sudoku_visiblefrom >>

Sudoku Toolbox >> Algorithms > sudoku_locatenakedsubset

sudoku_locatenakedsubset

Find naked subsets of given length and returns the associated rows and columns.

Calling Sequence

[nsrows,nscols] = sudoku_locatenakedsubset ( X , C , L , k )
[nsrows,nscols] = sudoku_locatenakedsubset ( X , C , L , k , stopatfirst )
[nsrows,nscols] = sudoku_locatenakedsubset ( X , C , L , k , stopatfirst , verbose )

Parameters

X:

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

k:

the length of the naked subset

stopatfirst:

if %t, then stop when one or more candidates have been removed. (default = %t)

verbose:

a boolean. Set to %t to display the state of the matrix. (default = %f)

nsrows:

a ns x k matrix, where ns is the number of naked subsets. nsrows(i,j) is the row index of the j-th cell of the i-th naked subset

nscols:

a ns x k matrix, where ns is the number of naked subsets. nscols(i,j) is the column index of the j-th cell of the i-th naked subset

Description

Search for naked subsets of length k and returns the rows and columns indices.

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);
sudoku_locatenakedsubset ( X , C , L , %t ); // Found triple {1,7,8} in row 1 at (1,2), (1,3), (1,6).

Authors


<< sudoku_issolved Algorithms sudoku_visiblefrom >>