This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package sudoku.structure;
|
||||
|
||||
import sudoku.constraint.IConstraint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -60,12 +62,20 @@ public class MultiDoku {
|
||||
}
|
||||
|
||||
public List<Integer> getPossibleSymbolsOfCell(Cell cellToFill) {
|
||||
for (Sudoku sudoku : this.subGrids) {
|
||||
if (sudoku.contains(cellToFill)) {
|
||||
return sudoku.getPossibleSymbolsOfCell(cellToFill);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
List<Integer> result = new ArrayList<>();
|
||||
boolean hasBeenFill = false;
|
||||
|
||||
for (Sudoku sudoku : this.subGrids) {
|
||||
if (sudoku.contains(cellToFill)) {
|
||||
if (!hasBeenFill) {
|
||||
result.addAll(sudoku.getPossibleSymbolsOfCell(cellToFill));
|
||||
hasBeenFill = true;
|
||||
} else {
|
||||
result.retainAll(sudoku.getPossibleSymbolsOfCell(cellToFill));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Sudoku> getSubGrids() {
|
||||
|
||||
@@ -152,7 +152,6 @@ public class SudokuFactory {
|
||||
*/
|
||||
|
||||
Sudoku sudoku1 = createSquareSudoku(size);
|
||||
|
||||
Sudoku sudoku2 = createSquareSudoku(size);
|
||||
Sudoku sudoku3 = createSquareSudoku(size);
|
||||
Sudoku sudoku4 = createSquareSudoku(size);
|
||||
|
||||
Reference in New Issue
Block a user