feat: added method to fill sudoku from integer list
All checks were successful
Linux arm64 / Build (push) Successful in 1m4s
All checks were successful
Linux arm64 / Build (push) Successful in 1m4s
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user