introduce bitloops
This commit is contained in:
@@ -58,7 +58,11 @@ public record Export() {
|
||||
}
|
||||
|
||||
record Gridded(@Delegate Grid grid) {
|
||||
|
||||
public boolean lisLetterAt(int pos) {
|
||||
if ((pos & 64) == 0)
|
||||
return lisLetterAtLo(pos);
|
||||
return lisLetterAtHi(pos);
|
||||
}
|
||||
public static IntStream walk(byte base, long lo, long hi) {
|
||||
if (Slot.increasing(base)) {
|
||||
return IntStream.concat(
|
||||
@@ -119,7 +123,7 @@ public record Export() {
|
||||
var offset = Grid.offset(r, c);
|
||||
if (clues.isClue(offset))
|
||||
sb.append((char) (48 | clues.digitAt(offset)));
|
||||
else if (grid.lisLetterAt(offset))
|
||||
else if (lisLetterAt(offset))
|
||||
sb.append((char) (64 | grid.letter32At(offset)));
|
||||
else
|
||||
sb.append(' ');
|
||||
@@ -144,7 +148,7 @@ public record Export() {
|
||||
var offset = Grid.offset(r, c);
|
||||
if (clues.isClue(offset)) {
|
||||
sb.append(clueChar.replace(new Cell(grid, clues, offset, clues.digitAt(offset))));
|
||||
} else if (grid.lisLetterAt(offset)) {
|
||||
} else if (lisLetterAt(offset)) {
|
||||
sb.append(NOT_CLUE_NOT_LETTER_TO(grid.letter32At(offset)));
|
||||
} else {
|
||||
sb.append(emptyFallback);
|
||||
@@ -192,7 +196,6 @@ public record Export() {
|
||||
|
||||
public record PuzzleResult(Clued mask, FillResult filled) {
|
||||
|
||||
boolean inBounds(int idx) { return idx >= 0 && idx < SwedishGenerator.SIZE; }
|
||||
Placed extractPlacedFromSlot(Slot s, long lemma) { return new Placed(lemma, s.key(), s.walk().toArray()); }
|
||||
public ExportedPuzzle exportFormatFromFilled(int difficulty, Rewards rewards) {
|
||||
var g = filled().grid();
|
||||
@@ -236,7 +239,6 @@ public record Export() {
|
||||
var letterAt = new HashMap<Integer, Character>();
|
||||
for (var p : placed) {
|
||||
for (var c : p.cells) {
|
||||
if (!inBounds(c)) throw new RuntimeException();
|
||||
if (mask.notClue(c) && g.lisLetterAt(c)) {
|
||||
letterAt.put(c, (char) (64 | g.letter32At(c)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user