update them
This commit is contained in:
@@ -217,7 +217,8 @@ public class DailyGenerator {
|
|||||||
sb.append(" \"direction\": \"").append(escapeJson(w.direction())).append("\",\n");
|
sb.append(" \"direction\": \"").append(escapeJson(w.direction())).append("\",\n");
|
||||||
sb.append(" \"answer\": \"").append(escapeJson(w.answer())).append("\",\n");
|
sb.append(" \"answer\": \"").append(escapeJson(w.answer())).append("\",\n");
|
||||||
sb.append(" \"arrowRow\": ").append(w.arrowRow()).append(",\n");
|
sb.append(" \"arrowRow\": ").append(w.arrowRow()).append(",\n");
|
||||||
sb.append(" \"arrowCol\": ").append(w.arrowCol()).append("\n");
|
sb.append(" \"arrowCol\": ").append(w.arrowCol()).append(",\n");
|
||||||
|
sb.append(" \"isReversed\": ").append(w.isReversed()).append("\n");
|
||||||
sb.append(" }");
|
sb.append(" }");
|
||||||
if (i < puzzle.words().size() - 1) sb.append(",");
|
if (i < puzzle.words().size() - 1) sb.append(",");
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ public final class ExportFormat {
|
|||||||
p.direction,
|
p.direction,
|
||||||
p.word, // answer
|
p.word, // answer
|
||||||
p.arrowRow - minR,
|
p.arrowRow - minR,
|
||||||
p.arrowCol - minC
|
p.arrowCol - minC,
|
||||||
|
p.isReversed
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +167,7 @@ public final class ExportFormat {
|
|||||||
// Canonicalize: always output right/down
|
// Canonicalize: always output right/down
|
||||||
int startRow, startCol, arrowRow, arrowCol;
|
int startRow, startCol, arrowRow, arrowCol;
|
||||||
String direction;
|
String direction;
|
||||||
|
boolean isReversed = false;
|
||||||
|
|
||||||
if (d == '2') { // right -> horizontal
|
if (d == '2') { // right -> horizontal
|
||||||
direction = "horizontal";
|
direction = "horizontal";
|
||||||
@@ -179,52 +181,35 @@ public final class ExportFormat {
|
|||||||
startCol = cells.get(0)[1];
|
startCol = cells.get(0)[1];
|
||||||
arrowRow = r;
|
arrowRow = r;
|
||||||
arrowCol = c;
|
arrowCol = c;
|
||||||
} else if (d == '4') { // left -> canonical right
|
} else if (d == '4') { // left -> horizontal (REVERSED)
|
||||||
direction = "horizontal";
|
direction = "horizontal";
|
||||||
var farLeft = cells.get(cells.size() - 1);
|
isReversed = true;
|
||||||
startRow = farLeft[0];
|
startRow = cells.get(0)[0];
|
||||||
startCol = farLeft[1];
|
startCol = cells.get(0)[1];
|
||||||
arrowRow = startRow;
|
arrowRow = r;
|
||||||
arrowCol = startCol - 1;
|
arrowCol = c;
|
||||||
} else if (d == '1') { // up -> canonical down
|
} else if (d == '1') { // up -> vertical (REVERSED)
|
||||||
direction = "vertical";
|
direction = "vertical";
|
||||||
var topMost = cells.get(cells.size() - 1);
|
isReversed = true;
|
||||||
startRow = topMost[0];
|
startRow = cells.get(0)[0];
|
||||||
startCol = topMost[1];
|
startCol = cells.get(0)[1];
|
||||||
arrowRow = startRow - 1;
|
arrowRow = r;
|
||||||
arrowCol = startCol;
|
arrowCol = c;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read word from grid in canonical order (right/down)
|
// Read word from grid using the collected cells
|
||||||
var wordChars = new StringBuilder();
|
var wordChars = new StringBuilder();
|
||||||
if ("horizontal".equals(direction)) {
|
for (var rc : cells) {
|
||||||
for (var i = 0; i < cells.size(); i++) {
|
wordChars.append(g[rc[0]][rc[1]]);
|
||||||
var cc2 = startCol + i;
|
|
||||||
var ch = (inBounds(H, W, startRow, cc2) ? g[startRow][cc2] : '#');
|
|
||||||
if (!isLetter(ch)) break;
|
|
||||||
wordChars.append(ch);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var i = 0; i < cells.size(); i++) {
|
|
||||||
var rr2 = startRow + i;
|
|
||||||
var ch = (inBounds(H, W, rr2, startCol) ? g[rr2][startCol] : '#');
|
|
||||||
if (!isLetter(ch)) break;
|
|
||||||
wordChars.append(ch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var word = wordChars.toString();
|
var word = wordChars.toString();
|
||||||
if (word.length() < minLen || word.length() > maxLen) return null;
|
if (word.length() < minLen || word.length() > maxLen) return null;
|
||||||
|
|
||||||
// Build exact used cells (only for actual word length)
|
// Build exact used cells (only for actual word length)
|
||||||
List<int[]> used = new ArrayList<>(word.length());
|
List<int[]> used = new ArrayList<>(cells);
|
||||||
if ("horizontal".equals(direction)) {
|
|
||||||
for (var i = 0; i < word.length(); i++) used.add(new int[]{ startRow, startCol + i });
|
|
||||||
} else {
|
|
||||||
for (var i = 0; i < word.length(); i++) used.add(new int[]{ startRow + i, startCol });
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Placed(
|
return new Placed(
|
||||||
word,
|
word,
|
||||||
@@ -236,7 +221,8 @@ public final class ExportFormat {
|
|||||||
arrowRow,
|
arrowRow,
|
||||||
arrowCol,
|
arrowCol,
|
||||||
used,
|
used,
|
||||||
new int[]{ arrowRow, arrowCol }
|
new int[]{ arrowRow, arrowCol },
|
||||||
|
isReversed
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +237,8 @@ public final class ExportFormat {
|
|||||||
* @param direction "horizontal" | "vertical"
|
* @param direction "horizontal" | "vertical"
|
||||||
* @param cells word cells
|
* @param cells word cells
|
||||||
* @param arrow [arrowRow, arrowCol] */
|
* @param arrow [arrowRow, arrowCol] */
|
||||||
private record Placed(String word, String clue, int startRow, int startCol, String direction, String answer, int arrowRow, int arrowCol, List<int[]> cells, int[] arrow) {
|
private record Placed(String word, String clue, int startRow, int startCol, String direction, String answer, int arrowRow, int arrowCol, List<int[]> cells, int[] arrow,
|
||||||
|
boolean isReversed) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +248,7 @@ public final class ExportFormat {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param direction "horizontal" | "vertical" */
|
* @param direction "horizontal" | "vertical" */
|
||||||
public record WordOut(String word, String clue, int startRow, int startCol, String direction, String answer, int arrowRow, int arrowCol) {
|
public record WordOut(String word, String clue, int startRow, int startCol, String direction, String answer, int arrowRow, int arrowCol, boolean isReversed) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ public class Main {
|
|||||||
sb.append(" \"direction\": \"").append(escapeJson(w.direction())).append("\",\n");
|
sb.append(" \"direction\": \"").append(escapeJson(w.direction())).append("\",\n");
|
||||||
sb.append(" \"answer\": \"").append(escapeJson(w.answer())).append("\",\n");
|
sb.append(" \"answer\": \"").append(escapeJson(w.answer())).append("\",\n");
|
||||||
sb.append(" \"arrowRow\": ").append(w.arrowRow()).append(",\n");
|
sb.append(" \"arrowRow\": ").append(w.arrowRow()).append(",\n");
|
||||||
sb.append(" \"arrowCol\": ").append(w.arrowCol()).append("\n");
|
sb.append(" \"arrowCol\": ").append(w.arrowCol()).append(",\n");
|
||||||
|
sb.append(" \"isReversed\": ").append(w.isReversed()).append("\n");
|
||||||
sb.append(" }");
|
sb.append(" }");
|
||||||
if (i < puzzle.words().size() - 1) sb.append(",");
|
if (i < puzzle.words().size() - 1) sb.append(",");
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user