Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, December 20, 2012

LearnStreet Sample Solution Sudoku Solver Project Method 4



function isPossibleNumber(sudoku, row, col, number) {
    // Now you will start using of the other methods you've written above.
    // This method accepts a 'sudoku' puzzle, a 'row' and a 'col' (column), and a
    // possible 'number' to move into that row/column position.
    // Such a move would be possible if: 1) isPossibleRow() returns true for
    // that row, and 2) ifPossibleColumn() returns true for that column, and
    // 3) isPossibleBlock() returns true for the block that sudoku[row][col] is
    // in. Use the getCellBlock() function below to find which block this is. If all of
    // these functions return true, then isPossibleNumber() should return true.
    // If any of the those functions returns false, then ifPossibleNumber() should
    // return false.
    // REPLACE THIS CODE WITH YOUR isPossibleNumber() METHOD
    var returnValue = false;
    var block = getCellBlock(row,col);
    if(isPossibleRow(sudoku, row, number) && isPossibleColumn(sudoku, col, number) && isPossibleBlock(sudoku, block, number)){
        returnValue = true;
    }
    return returnValue;
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts