Skip to content

Instantly share code, notes, and snippets.

@jezinka

jezinka/SudokuBacktracking.groovy Secret

Last active May 24, 2020
Embed
What would you like to do?
step
void step() {
if (isFixedNumber["$rowIndex$columnIndex" as String]) {
nextCell()
} else {
int cell = board[rowIndex][columnIndex]
int value = ++cell
if (value <= 9) {
board[rowIndex][columnIndex] = value
if (this.isValid()) {
nextCell()
}
} else {
board[rowIndex][columnIndex] = 0
do {
previousCell()
} while (isFixedNumber["$rowIndex$columnIndex" as String])
}
}
printTable()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment