Fixes #14
All checks were successful
Linux arm64 / Build (push) Successful in 40s

This commit is contained in:
2025-01-30 14:51:21 +01:00
parent d6c3504bc7
commit 8596781ce3
3 changed files with 97 additions and 22 deletions

View File

@@ -291,4 +291,28 @@ public class SudokuFactory {
return null;
}
}
public static MultiDoku createBasicEmptyRandomBlockDoku(int blockSize, List<Constraint> constraints) {
int blockCellCount = blockSize * blockSize;
List<Cell> cells = initCells(blockCellCount);
List<Cell> homeLessCells = new ArrayList<>();
homeLessCells.addAll(cells);
List<Block> blocks = new ArrayList<>();
Random r = new Random();
for (int i = 0 ; i < blockCellCount; i++) {
Block b = new Block();
for (int j = 0; j < blockCellCount; j++) {
int cellIndex = r.nextInt(homeLessCells.size());
Cell cell = homeLessCells.remove(cellIndex);
b.addCell(cell);
cell.setBlock(b);
}
blocks.add(b);
}
Sudoku sudoku = new Sudoku(cells, blocks, constraints);
for (Block block : blocks) {
block.getSudokus().add(sudoku);
}
return new MultiDoku(Arrays.asList(sudoku));
}
}