This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void fillCandidates() { | |
for (int i = 0; i < board.length; i++) { | |
for (int j = 0; j < board[i].length; j++) { | |
Cell cell = board[i][j] | |
if (cell.value == 0) { | |
cell.candidates = (1..9) | |
removeKnown(i, j) | |
assert cell.candidates.size() > 0 | |
} else { | |
cell.candidates = [] | |
} | |
} | |
} | |
} | |
void removeKnown(int rowNum, int colNum) { | |
Cell cell = board[rowNum][colNum] | |
cell.candidates -= getValuesForColumn(colNum) | |
cell.candidates -= getValuesForRecord(rowNum) | |
cell.candidates -= getValuesForSquare(rowNum, colNum) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment