feat : logger
Some checks failed
Linux arm64 / Build (push) Has been cancelled

This commit is contained in:
Melvyn
2025-01-28 09:59:51 +01:00
parent b1ae79a2e8
commit ebb3a4c48a
4 changed files with 48 additions and 8 deletions

View File

@@ -20,4 +20,27 @@ public class SudokuPrinter {
System.out.println(line);
}
}
public static String toStringRectangleSudoku(final Sudoku s, int blockWidth, int blockHeight) {
StringBuilder result = new StringBuilder();
for (int y = 0; y < s.getSize(); y++) {
// Ajouter une ligne vide entre les blocs horizontaux
if (y % blockHeight == 0 && y > 0) {
result.append("\n");
}
StringBuilder line = new StringBuilder("[ ");
for (int x = 0; x < s.getSize(); x++) {
// Ajouter la valeur de la cellule
line.append((s.getCell(x, y).getSymbolIndex() + 1)).append(" ");
// Ajouter un séparateur vertical entre les blocs
if (x % blockWidth == blockWidth - 1 && x != s.getSize() - 1) {
line.append("| ");
}
}
line.append("]");
result.append(line).append("\n");
}
return result.toString();
}
}