feat: added method to fill sudoku from integer list
All checks were successful
Linux arm64 / Build (push) Successful in 1m4s

This commit is contained in:
fl.du.pr Grens
2025-01-21 21:42:39 +01:00
parent f44311fd5c
commit 38d1bc466f
3 changed files with 36 additions and 23 deletions

View File

@@ -31,7 +31,7 @@ public class Sudoku {
/**
* Try to place a cell at the given coordinate
*
*
* @return false if it can't be done
*/
public boolean setCellSymbol(int x, int y, int value) {
@@ -49,6 +49,21 @@ public class Sudoku {
return false;
}
public boolean setCellsSymbol(List<Integer> values) {
if (values.size() > this.cells.size()) {
return false;
}
for (int i = 0; i < values.size(); i++) {
int x = i%this.blocks.size();
int y = (i-x)/this.blocks.size();
if (!this.setCellSymbol(x, y, values.get(i))) {
return false;
}
}
return true;
}
public Cell getCell(int x, int y) {
int index = y * getSize() + x;
assert (isValidCoords(x, y));