<< sudoku_islatin Algorithms sudoku_locatenakedsubset >>

Sudoku Toolbox >> Algorithms > sudoku_issolved

sudoku_issolved

See if the sudoku is solved.

Calling Sequence

[solved,code,irow,icol] = sudoku_issolved ( X )

Parameters

X:

a 9x9 matrix, with 0 for unknown entries

solved:

a boolean, %t if the sudoku X is solved

code:

a string. If code="totalsum", then the total of the entries is not 405. If code="subsquare" then a subsquare has a sum different from 45. If code="rowsum", then the sum of entries in a row is not 45. If code="colsum", then the sum of entries in a column is not 45.

irow:

an empty matrix, or the integer for the failing row or failing subsquare row.

icol:

an empty matrix, or the integer for the failing column or failing subsquare column.

Description

Find out if the solution is found.

Examples

X = [
6    7    3    1    5    8    2    4    9
4    1    8    2    6    9    5    3    7
2    9    5    4    3    7    8    6    1
5    8    2    3    4    1    7    9    6
3    4    7    6    9    2    1    8    5
1    9    6    7    8    5    3    2    4
7    5    4    8    2    6    9    1    3
2    3    1    9    7    4    6    5    8
8    6    9    5    1    3    4    7    2
];
[solved,code,irow,icol] = sudoku_issolved(X)

X = [
6    7    3    1    5    8    2    4    9
4    1    8    2    6    9    5    3    7
9    2    5    4    3    7    8    6    1
5    8    2    3    4    1    7    9    6
3    4    7    6    9    2    1    8    5
1    9    6    7    8    5    3    2    4
7    5    4    8    2    6    9    1    3
2    3    1    9    7    4    6    5    8
8    6    9    5    1    3    4    7    2
];
[solved,code,irow,icol] = sudoku_issolved(X)

Authors

<< sudoku_islatin Algorithms sudoku_locatenakedsubset >>