Skip to content

Instantly share code, notes, and snippets.

@jezinka

jezinka/Board.groovy Secret

Created Oct 17, 2018
Embed
What would you like to do?
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