"""Bounded NEW 37-base experiments; Python 3.10+, standard library only. Source seed: Solve@Home return 936, coverage_repair.json sha256 6bb86ff52f9e88feca24cd3325dcdfad7852a1548a10c004cb93bbb6232e08ed. Does not reproduce its old-base exhaustive scan. Output is deterministic JSON; process CPU/wall timing goes to stderr. --output is for native Windows launcher. All scientific arrays are bounded by the CLI choices below; output <= 1 MiB. """ import argparse, json, math, pathlib, sys, time P = 200560490130 PP = 37 * P Q = (41, 43, 47, 53, 59, 61, 67, 71, 73) OLD_PHASES = {37:5, 41:31, 43:42, 47:0, 53:29, 59:29, 61:7, 67:14, 71:59} OLD_FIRST, OLD_LAST = 20283513461, 20283514499 def slots(lo, hi): # 2 and 3 force r=5 mod 6, including r=-1 at the period seam. return [x for x in range(lo + (5-lo)%6, hi+1, 6) if math.gcd(x, PP)==math.gcd(x+2, PP)==1] def valid(xs, phases): return bool(xs) and xs == slots(xs[0], xs[-1]) and all( any((x-a)%q in (0,q-2) for q,a in phases.items()) for x in xs) class Limit(Exception): pass def solve(xs, maxnodes=50000): masks=[] for q in Q: bymask={} for a in range(q): m=sum(1<maxnodes: raise Limit() if not todo: return [] if not primes: return None key=(todo,primes) if key in failed: return None active=[k for k in range(len(Q)) if primes>>k&1] if sum(max((m&todo).bit_count() for m,a in masks[k]) for k in active)L and len(head)>L xx=tail[-L:]+[x+PP for x in head[:L]] out['windows']=[] for j in range((L+1)//2): w=xx[j:j+L]; phases,stats,result=solve(w) out['windows'].append({'offset_from_N':-L+j,'first':w[0], 'last':w[-1], 'result':result,**stats,'phases':phases}) elif args.mode=='local': xx=slots(OLD_FIRST+shift-500,OLD_LAST+shift+500) assert len(xx)<150 out['windows']=[] for L in range(29,35): for j in range(len(xx)-L+1): w=xx[j:j+L]; phases,stats,result=solve(w,20000) rec={'L':L,'first':w[0],'last':w[-1],'result':result,**stats} if phases: rec.update(slots=w,phases=phases) out['windows'].append(rec) if result=='cover': break if result=='node_limit': break else: # A distinct new-base L34 prefix microbenchmark, intentionally small. xx=slots(0,30000) assert len(xx)<2000 and len(xx)>534 out['windows']=[] for j in range(500): w=xx[j:j+34]; phases,stats,result=solve(w,20000) out['windows'].append({'index':j,'first':w[0],'last':w[-1],'result':result,**stats,'phases':phases}) if result=='node_limit': break raw=json.dumps(out,sort_keys=True,indent=2)+'\n' assert len(raw.encode())<=1048576 if args.output: pathlib.Path(args.output).write_text(raw,encoding='utf-8') else: print(raw,end='') print(json.dumps({'process_cpu_seconds':time.process_time()-t0,'wall_seconds':time.perf_counter()-wall}),file=sys.stderr) if __name__=='__main__': main()