function isSolved(sudoku) {
// A sudoku will be solved if all its rows, columns and blocks are correct.
// Use a combination of the previous three functions -- isCorrectRow(),
// isCorrectColumn(), and isCorrectBlock() -- to determine if the 'sudoku'
// is solved and return true if this is the case. If the sudoku is not solved,
// you should return false.
// REPLACE THIS CODE WITH YOUR isSolved() METHOD
var returnValue = true;
//var block = getCellBlock(row,col);
for(var i=0; i<9; i++){
if(!isCorrectRow(sudoku, i)){
returnValue = false;
}
if(!isCorrectColumn(sudoku, i)){
returnValue = false;
}
if(!isCorrectBlock(sudoku, i)){
returnValue = false;
}
}
return returnValue;
}
No comments:
Post a Comment