<< sudoku_findnakedsubset Algorithms sudoku_findxcycle >>

Sudoku Toolbox >> Algorithms > sudoku_findtwocolors

sudoku_findtwocolors

Search for pairs.

Calling Sequence

[ X , C , L ] = sudoku_findtwocolors ( X , C , L )
[ X , C , L ] = sudoku_findtwocolors ( X , C , L , stopatfirst )
[ X , C , L ] = sudoku_findtwocolors ( X , C , L , stopatfirst , verbose )

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

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)

Description

Color the sudoku with 2 colors and find inconsistencies. The algorithm is the following: * compute conjugate pairs (i.e. pairs of two cells which are the only 2 candidates in their rows, columns or blocks), * add coloring with 2 colors, * make deductions: * strategy #1 : if there are two colored cells with color X in the same row, column or block, remove the candidate d in these cells, * strategy #2 : if there exist one uncolored cell A visible by two colored cells, then A is not a candidate of the uncolored cell. The Turbot-fish strategy is superseded by the 2-colors strategy.

Examples

X = [
1 9 6   4 5 3   7 2 8
4 3 0   7 6 0   9 5 1
0 5 7   0 1 9   4 6 3
..
3 6 5   9 8 7   1 4 2
9 8 4   1 2 5   6 3 7
7 2 1   6 3 4   8 9 5
..
6 7 0   0 4 1   5 8 9
0 4 9   0 7 0   3 1 6
0 1 0   0 9 6   2 7 4
];
[C,L] = sudoku_candidates(X);
X = sudoku_findtwocolors ( X , C , L , %f , %t );

Authors

Bibliography

Angus Johnson, http://www.angusj.com/sudoku/hints.php

<< sudoku_findnakedsubset Algorithms sudoku_findxcycle >>