<< sudoku_solve Solve sudoku_solvebylogic >>

Sudoku Toolbox >> Solve > sudoku_solveai

sudoku_solveai

Solves Sudoku.

Calling Sequence

Y = sudoku_solveai ( X )
Y = sudoku_solveai ( X , verbose )
[Y,iter,C,L] = sudoku_solveai ( ... )

Parameters

X:

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

verbose:

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

Y:

a 9-by-9 matrix. If Y contains zeros, they stand for unsolved entries. The test and(Y(:) > 0) allows to see if the puzzle is solved.

iter:

the number of steps required by each algorithm

iter(1):

number naked singles steps

iter(2):

number hidden singles steps

iter(3):

number locked candidates steps

iter(4):

number naked pairs steps

iter(5):

number hidden pair steps

iter(6):

number naked triples steps

iter(7):

number hidden triples steps

iter(8):

number naked quad steps

iter(9):

number hidden quad steps

C:

a cell array of candidate vectors for each cell.

L:

the number of candidates for each cell

Description

Uses a method designed by Arto Inkala: 1. put candidate to its' cell 2. check if any of the conflict appear 3. eliminate all candidates, which cause conflict in the new situation 4. repeat 2 and 3 until conflict appear of eliminations are not possible

Examples

X = [
0 0 0   0 0 0   0 0 0
0 0 0   0 0 0   5 3 0
9 0 0   0 3 7   0 0 0
0 0 2   3 0 1   0 9 6
0 4 7   6 9 0   1 8 0
0 0 6   7 8 5   0 0 0
0 5 0   0 2 0   9 0 3
0 3 0   9 0 0   6 0 8
8 0 0   0 1 0   4 7 0
]
sudoku_solveai(X)
sudoku_solveai(X,%t)

Authors

Bibliography

"AI Escargot - The Most Difficult Sudoku Puzzle", Arto Inkala, 2007


<< sudoku_solve Solve sudoku_solvebylogic >>