feat : solver + test
All checks were successful
Linux arm64 / Build (push) Successful in 5m9s

This commit is contained in:
Melvyn
2025-01-23 23:20:16 +01:00
parent 6902321101
commit 483b286bac
13 changed files with 292 additions and 183 deletions

View File

@@ -1,14 +1,15 @@
package sudoku.constraint;
import sudoku.Block;
import sudoku.Cell;
import sudoku.Sudoku;
public class BlockConstraint implements IConstraint{
@Override
public boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex) {
Block bloc = s.getCell(x, y).getBlock();
return !bloc.containsSymbol(newSymbolIndex);
Block block = s.getCell(x, y).getBlock();
return !block.containsSymbol(newSymbolIndex);
}
}

View File

@@ -7,7 +7,7 @@ public class ColumnConstraint implements IConstraint {
@Override
public boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex) {
for (int i = 0; i < s.getSize(); i++) {
if (s.getCell(x, newSymbolIndex).getSymbolIndex() == newSymbolIndex)
if (s.getCell(x, i).getSymbolIndex() == newSymbolIndex)
return false;
}
return true;

View File

@@ -7,7 +7,7 @@ public class LineConstraint implements IConstraint {
@Override
public boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex) {
for (int i = 0; i < s.getSize(); i++) {
if (s.getCell(newSymbolIndex, y).getSymbolIndex() == newSymbolIndex)
if (s.getCell(i, y).getSymbolIndex() == newSymbolIndex)
return false;
}
return true;