introduce bitloops

This commit is contained in:
mike
2026-01-21 06:38:25 +01:00
parent dd53009e69
commit 1e13d39153
46 changed files with 51 additions and 150429 deletions

View File

@@ -40,21 +40,12 @@ import static java.nio.charset.StandardCharsets.US_ASCII;
)
public record SwedishGenerator() {
public static final long X = 0L;
public static final int C = Neighbors9x8.C;
public static final int R = Neighbors9x8.R;
public static final int SIZE = Neighbors9x8.SIZE;// ~18
public static final int SIZE_MIN_1 = Neighbors9x8.SIZE_MIN_1;// ~18
public static final double SIZED = Neighbors9x8.SIZED;// ~18
public static final int MAX_WORD_LENGTH = Neighbors9x8.R;
public static final int MAX_WORD_LENGTH_PLUS_ONE = MAX_WORD_LENGTH + 1;
public static final int MIN_LEN = Neighbors9x8.MIN_LEN;//Config.MIN_LEN;
public static final int MAX_TRIES_PER_SLOT = 500;//Config.MAX_TRIES_PER_SLOT;
public static final int STACK_SIZE = 128;
public static final long RANGE_0_SIZE = Neighbors9x8.RANGE_0_SIZE;// (long) SIZE_MIN_1 - 0L + 1L
public static final long RANGE_0_624 = Neighbors9x8.RANGE_0_624;//624L - 0L + 1L;
static final int PICK_NOT_DONE = -1;
static final int PICK_DONE = 0;
public static final long X = 0L;
public static final int SIZE = Neighbors9x8.SIZE;// ~18
public static final int MAX_TRIES_PER_SLOT = 500;//Config.MAX_TRIES_PER_SLOT;
public static final long RANGE_0_SIZE = Neighbors9x8.RANGE_0_SIZE;// (long) SIZE_MIN_1 - 0L + 1L
public static final long RANGE_0_624 = Neighbors9x8.RANGE_0_624;//624L - 0L + 1L;
public static boolean isLo(int n) { return (n & 64) == 0; }
interface Bit1029 {
@@ -120,9 +111,9 @@ public record SwedishGenerator() {
for (long w = word & LETTER_MASK; w != 0; w >>>= 5) bytes[bi++] = (byte) ((w & 31) | 64);
return new String(bytes, 0, bi, US_ASCII);
}
static int unpackIndex(long w) { return (int) (w >>> 40); }
static int unpackSize(long w) { return (int) (w >>> 40) & 7; }
static int unpackLetters(long w) { return (int) (w & LETTER_MASK); }
static int unpackIndex(long w) { return (int) (w >>> 40); }
static int unpackSize(long w) { return (int) (w >>> 40) & 7; }
static int unpackLetters(long w) { return (int) (w & LETTER_MASK); }
static long pack43(long w) {
return w & INDEX_MASK;
}
@@ -213,6 +204,8 @@ public record SwedishGenerator() {
val t0 = System.currentTimeMillis();
class Solver {
static final int PICK_NOT_DONE = -1;
static final int PICK_DONE = 0;
long nodes;
long backtracks;
long glo = grid.lo, ghi = grid.hi;