23 lines
533 B
Java
23 lines
533 B
Java
package sudoku.constraint;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import sudoku.structure.Sudoku;
|
|
|
|
public interface IConstraint extends Serializable {
|
|
boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex);
|
|
|
|
default List<Integer> getPossibleSymbols(final Sudoku s, int x, int y) {
|
|
List<Integer> possibilities = new ArrayList<>();
|
|
for (int i = 0; i < s.getSize(); i++) {
|
|
if (canBePlaced(s, x, y, i)) {
|
|
possibilities.add(i);
|
|
}
|
|
}
|
|
return possibilities;
|
|
}
|
|
|
|
}
|