fix previous commit

This commit is contained in:
2025-01-28 11:30:09 +01:00
parent 5eabf87c94
commit c430a1e1b0

View File

@@ -2,6 +2,7 @@ package sudoku.solver;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import sudoku.structure.Coordinate;
import sudoku.structure.MultiDoku; import sudoku.structure.MultiDoku;
import sudoku.structure.Sudoku; import sudoku.structure.Sudoku;
@@ -23,9 +24,9 @@ public class StupidSolver {
if (!sudoku.getCell(index).isMutable()) if (!sudoku.getCell(index).isMutable())
return solve(sudoku, index + 1); return solve(sudoku, index + 1);
var coords = sudoku.toCoords(index); Coordinate coords = sudoku.toCoords(index);
for (int symbol = 0; symbol < sudoku.getSize(); symbol++) { for (int symbol = 0; symbol < sudoku.getSize(); symbol++) {
if (sudoku.tryPlaceCellSymbol(coords[0], coords[1], symbol)) { if (sudoku.tryPlaceCellSymbol(coords.getX(), coords.getY(), symbol)) {
// on tente de placer sur la case suivante // on tente de placer sur la case suivante
if (solve(sudoku, index + 1)) { if (solve(sudoku, index + 1)) {
return true; return true;
@@ -33,7 +34,7 @@ public class StupidSolver {
} }
} }
// on a tout essayé et rien n'a fonctionné // on a tout essayé et rien n'a fonctionné
sudoku.clearCell(coords[0], coords[1]); sudoku.clearCell(coords.getX(), coords.getY());
return false; return false;
} }