Find naked subsets of given length.
[X,C,L] = sudoku_findhiddensubset ( X , C , L , k ) [X,C,L] = sudoku_findhiddensubset ( X , C , L , k , stopatfirst ) [X,C,L] = sudoku_findhiddensubset ( X , C , L , k , stopatfirst , verbose )
a 9-by-9 matrix, with 0 for unknown entries
a 9 x 9 cell of candidates
the 9 x 9 matrix of number candidates
the length of the naked subset
if %t, then stop when one or more candidates have been removed. (default = %t)
a boolean. Set to %t to display the state of the matrix. (default = %f)
Search for hidden subsets of length k. For example, k=1 finds hidden singles, k=2 finds hidden pairs, k=3 finds hidden triples and k=4 finds hidden quads.
The algorithm computes a merged list of all candidates in the row, column or block. This merged list is simplified and only unique candidates are kept. The list is used to generate all combinations of k elements. Each combination S is searched in the row, column or block. The row, column or block contains a hidden subset of length k if exactly k cells are so that any item in S is contained in the candidates of each cell. If a hidden subset of length k is found, the candidates which are not in S are removed from the k cells.
This generic algorithm can be specialized to find hidden pairs, hidden triples, hidden quads, hidden sextets, hidden septets and hidden octets. See the note in findnakedsubset.
See the note on interrupting the algorithm.