This commit is contained in:
mike
2026-01-23 21:20:08 +01:00
parent 7e34276726
commit e9d787bbb9
6 changed files with 91 additions and 95 deletions

View File

@@ -8,6 +8,8 @@ import puzzle.Meta.ShardLem;
import puzzle.SwedishGenerator.Lemma;
import puzzle.SwedishGenerator.Slotinfo;
import java.util.Arrays;
import java.util.function.IntSupplier;
import java.util.stream.IntStream;
import static precomp.Const9x8.CLUE_DOWN0;
import static precomp.Const9x8.CLUE_LEFT3;
import static precomp.Const9x8.CLUE_LEFT_TOP4;
@@ -17,6 +19,53 @@ import static precomp.Const9x8.CLUE_RIGHT_TOP5;
import static precomp.Const9x8.CLUE_UP2;
public class Riddle {
public static IntStream cellWalk(int base, long lo, long hi) {
if (Slotinfo.increasing(base)) {
return IntStream.concat(IntStream.of(Slot.clueIndex(base)), IntStream.concat(
IntStream.generate(new IntSupplier() {
long temp = lo;
@Override
public int getAsInt() {
int res = Long.numberOfTrailingZeros(temp);
temp &= temp - 1;
return res;
}
}).limit(Long.bitCount(lo)),
IntStream.generate(new IntSupplier() {
long temp = hi;
@Override
public int getAsInt() {
int res = 64 | Long.numberOfTrailingZeros(temp);
temp &= temp - 1;
return res;
}
}).limit(Long.bitCount(hi))));
} else {
return IntStream.concat(IntStream.of(Slot.clueIndex(base)), IntStream.concat(
IntStream.generate(new IntSupplier() {
long temp = hi;
@Override
public int getAsInt() {
int msb = 63 - Long.numberOfLeadingZeros(temp);
temp &= ~(1L << msb);
return 64 | msb;
}
}).limit(Long.bitCount(hi)),
IntStream.generate(new IntSupplier() {
long temp = lo;
@Override
public int getAsInt() {
int msb = 63 - Long.numberOfLeadingZeros(temp);
temp &= ~(1L << msb);
return msb;
}
}).limit(Long.bitCount(lo))));
}
}
@AllArgsConstructor
enum Clue {
DOWN0(CLUE_DOWN0, 'B', 'b'),
@@ -83,4 +132,11 @@ public class Riddle {
meta.simpel(), meta.clues());
}
}
@FunctionalInterface
static
interface ClueSign {
char replace(byte data);
}
}