Gather data

This commit is contained in:
mike
2026-01-06 05:01:17 +01:00
parent 7705873798
commit ac81bc6032
2 changed files with 122 additions and 95 deletions

View File

@@ -27,8 +27,8 @@ public final class ExportFormat {
public static ExportedPuzzle exportFormatFromFilled(PuzzleResult puz, int difficulty, Rewards rewards) {
Objects.requireNonNull(puz, "puz");
var g = puz.filled().grid();
var H = g.length;
var W = g[0].length;
var H = g.H();
var W = g.W();
// 1) extract "placed" list from all clue digits in the filled grid
var placed = new ArrayList<Placed>();
@@ -47,10 +47,10 @@ public final class ExportFormat {
// If nothing placed: return full grid mapped to letters/# only
if (placed.isEmpty()) {
List<String> gridv2 = new ArrayList<>(H);
for (var chars : g) {
for (var r = 0; r < H; r++) {
var sb = new StringBuilder(W);
for (var c = 0; c < W; c++) {
var ch = chars[c];
var ch = g.getCharAt(r, c);
sb.append(isLetter(ch) ? ch : '#');
}
gridv2.add(sb.toString());
@@ -81,8 +81,8 @@ public final class ExportFormat {
for (var p : placed) {
for (var rc : p.cells) {
int rr = rc[0], cc = rc[1];
if (inBounds(H, W, rr, cc) && isLetter(g[rr][cc])) {
letterAt.put(pack(rr, cc), g[rr][cc]);
if (inBounds(H, W, rr, cc) && isLetter(g.getCharAt(rr, cc))) {
letterAt.put(pack(rr, cc), g.getCharAt(rr, cc));
}
}
}