1
0
Fork 0
forked from len0rd/rockbox

sudoku: fix FS#7772: Sudoku: "Solve" Crash.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24024 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2009-12-16 11:53:36 +00:00
parent 4e89025935
commit d9002eb94a
3 changed files with 48 additions and 3 deletions

View file

@ -1153,3 +1153,34 @@ bool sudoku_generate_board(struct sudoku_state_t* state, char** difficulty)
*difficulty = classify( );
return true;
}
bool sudoku_solve_board(struct sudoku_state_t* state)
{
bool ret;
int r,c,i;
reset( );
i=0;
for (r=0;r<9;r++) {
for (c=0;c<9;c++) {
if( state->startboard[r][c]!='0' )
{
fill( i, state->startboard[r][c] - '0' );
}
i++;
}
}
ret = ( 0 == solve( ) && 81 == idx_history );
if (ret) {
i=0;
for (r=0;r<9;r++) {
for (c=0;c<9;c++) {
state->currentboard[r][c]='0'+GET_DIGIT( board[ i ] );
i++;
}
}
}
return ret;
}