feat: dynamic constraints (Fixes #8)
All checks were successful
Linux arm64 / Build (push) Successful in 37s

This commit is contained in:
2025-01-29 17:19:44 +01:00
parent 5e26bea609
commit c16f2b8f5a
12 changed files with 311 additions and 149 deletions

View File

@@ -18,30 +18,29 @@ public class Main {
int blockWidth = 2;
int blockHeight = 2;
var multidoku = SudokuFactory.createBasicEmptyRectangleSudoku(blockWidth, blockHeight);
var multidoku = SudokuFactory.createBasicEmptyRectangleDoku(blockWidth, blockHeight,
SudokuFactory.DEFAULT_CONSTRAINTS);
var sudoku = multidoku.getSubGrid(0);
if(!sudoku.setCellsSymbol(Arrays.asList(0,1,2,3, 2,3,1,1, 1,0,3,2, 3,2,1,1))){
if (!sudoku.setCellsSymbol(Arrays.asList(0, 1, 2, 3, 2, 3, 1, 1, 1, 0, 3, 2, 3, 2, 1, 1))) {
System.out.println("At least one of those values does not respect the constraints.");
}
// sudoku.setCellSymbol(8,3,0);
//sudoku.setCellSymbol(8,3,0);
SudokuPrinter.printRectangleSudoku(multidoku.getSubGrid(0), blockWidth , blockHeight);
SudokuPrinter.printRectangleSudoku(multidoku.getSubGrid(0), blockWidth, blockHeight);
/*
Solver solver = new Solver();
ArrayList<IConstraint> constraints = new ArrayList<>();
constraints.add(new LineConstraint());
constraints.add(new ColumnConstraint());
constraints.add(new BlockConstraint());
try {
solver.solve(multidoku, constraints);
} catch (Exception e) {
System.out.println(e);
}
*/
* Solver solver = new Solver();
* ArrayList<IConstraint> constraints = new ArrayList<>();
* constraints.add(new LineConstraint());
* constraints.add(new ColumnConstraint());
* constraints.add(new BlockConstraint());
* try {
* solver.solve(multidoku, constraints);
* } catch (Exception e) {
* System.out.println(e);
* }
*/
}
}