1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| public class Solver {
public void solve() {
...
if (!prune()) solve();
...
}
private boolean prune() {
/* We'll use the processed field of board cells to avoid
infinite loops */
board.resetProcessed();
for (int i = 0; i < Board.NUMBEROFCELLS; i++) {
if (board.getBoardCell(i).getIslandSize()%Piece.NUMBEROFCELLS != 0) {
// We have found an unsolvable island
return true;
}
}
return false;
}
}
|