function isCorrectColumn(sudoku, col) {
// This method should return true if all the numbers from 1 to 9
// are present in the column indexed by the 'col' argument in the
// 'sudoku' puzzle. It should return false if the column is incomplete
// or has duplicates.
// This method is analogous to the isCorrectRow() method above.
// REPLACE THIS CODE WITH YOUR isCorrectColumn() METHOD
var returnValue = true;
var colCopy = [];
for(var i=0; i<9; i++){
colCopy[i] = sudoku[i][col];
}
colCopy.sort();
for(var i=1; i<=9; i++){
if(colCopy[i-1]!==i){
returnValue = false;
}
}
return returnValue;
}
No comments:
Post a Comment