consistent method
Validates board
consistency from the position of a cell into an index
Used by solve and checkAmbiguity to validate c
.
Will return true if c
does not violate board.
Implementation
bool consistent(Grid board, Position pos, int c) {
// Checks columns and rows
for (int i = 0; i < 9; i++) {
if (board.matrix()![pos.grid!.x as int][i].getValue() == c ||
board.matrix()![i][pos.grid!.y as int].getValue() == c) return false;
}
// Checks segment of grid
for (Cell cell in board.getSegment(pos)) {
if (cell.getValue() == c) {
return false;
}
}
return true;
}