introduce bitloops
This commit is contained in:
@@ -436,6 +436,23 @@ public record Masker(Rng rng, int[] stack, Clues cache) {
|
||||
public long rhi() { return rhi; }
|
||||
|
||||
public static Clues createEmpty() { return new Clues(0, 0, 0, 0, 0, 0); }
|
||||
public static Clues parse(String s) {
|
||||
var c = createEmpty();
|
||||
var lines = s.split("\n");
|
||||
for (int r = 0; r < Math.min(lines.length, R); r++) {
|
||||
var line = lines[r];
|
||||
for (int col = 0; col < Math.min(line.length(), C); col++) {
|
||||
char ch = line.charAt(col);
|
||||
if (ch >= '0' && ch <= '3') {
|
||||
int idx = Grid.offset(r, col);
|
||||
byte dir = (byte) (ch - '0');
|
||||
if ((idx & 64) == 0) c.setClueLo(1L << idx, dir);
|
||||
else c.setClueHi(1L << (idx & 63), dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
public boolean cluelessLo(int idx) {
|
||||
if (!isClueLo(idx)) return false;
|
||||
clearClueLo(~(1L << idx));
|
||||
@@ -506,7 +523,7 @@ public record Masker(Rng rng, int[] stack, Clues cache) {
|
||||
}
|
||||
}
|
||||
|
||||
static record Slot(int key, long lo, long hi, DictEntry entry) {
|
||||
public record Slot(int key, long lo, long hi, DictEntry entry) {
|
||||
|
||||
static final int BIT_FOR_DIR = 2;
|
||||
static Slot from(int key, long lo, long hi, DictEntry entry) { return new Slot(key, lo, hi, entry); }
|
||||
|
||||
Reference in New Issue
Block a user