// Question: which accepted adjacent-kill results are determined by a gap // histogram alone, and which permutation controls preserve them exactly? // Job 678, source grid return 161, transport connection return 159. // No new local-criterion priority or asymptotic theorem is claimed. 'use strict'; const fs=require('node:fs'),assert=require('node:assert/strict'); const reference=JSON.parse(fs.readFileSync(process.argv[2]||'kill-histogram-reference.json','utf8')); const started=Date.now(); function primesUpTo(n){const sieve=new Uint8Array(n+1),out=[];for(let i=2;i<=n;i++)if(!sieve[i]){out.push(i);for(let j=i*i;j<=n;j+=i)sieve[j]=1;}return out;} const primes=primesUpTo(1009); const expectedG={5:12,7:30,11:42,13:66,17:108,19:150,23:204,29:258}; function histogram(x){ const base=primes.filter(p=>p<=x),W=base.reduce((a,p)=>a*p,1),classes=[11,17,29]; const mask=new Uint8Array(W/10);mask.fill(1); // The 30-wheel has three twin-opening classes, including 29. This is the // complete twin-slot tile, not the two-class line used in the prior job. for(const p of base.filter(p=>p>=7))for(let c=0;c<3;c++)for(const target of [0,p-2]){ let k=0;while((30*k+classes[c])%p!==target)k++; for(let index=3*k+c;indexp>=3).reduce((n,p)=>n*(p-2),1)); assert.equal(total,D);assert.equal(period,W);assert.equal(G,expectedG[x]); return {x,W,D,G,first,support}; } function edgeCount(H,p){ let E=0; for(const {gap:g,count:n} of H.support){const r=g%p;if(r===0)E+=2*n;else if(r===2||r===p-2)E+=n;} return E; } function distinctPrimeFactors(n){const out=[];for(const p of primes){if(p*p>n)break;if(n%p===0){out.push(p);while(n%p===0)n/=p;}}if(n>1)out.push(n);return out;} function exceptionSupport(H){ const witness=new Map(); for(const {gap:g,count} of H.support)for(const n of [g,g-2,g+2])for(const p of distinctPrimeFactors(n)){ if(p>=7 && p>=H.x && !witness.has(p))witness.set(p,{p,gap:g,gapCount:count}); } return Array.from(witness.values()).sort((a,b)=>a.p-b.p); } function toyL(word,p){ let maximum=1; for(let start=0;start({support:word.map(gap=>({gap,count:1}))}); assert.equal(edgeCount(toySupport(toyA),7),edgeCount(toySupport(toyB),7)); assert.equal(toyL(toyA,7),3);assert.equal(toyL(toyB,7),2); const tiles=reference.tiles.map(x=>{const H=histogram(x);process.stderr.write(`Complete T${x}: ${Dformat(H.D)}, ${(Date.now()-started)/1000}s total\n`);if(global.gc)global.gc();return H;}); function Dformat(D){return String(D);} const predictions=[];let checked=0; for(const row of reference.rows)for(let column=0;column{ const exceptions=exceptionSupport(H),critical=exceptions.length?exceptions[exceptions.length-1].p:null; const onset=critical===null?primes.find(p=>p>=7&&p>=H.x):primes.find(p=>p>critical); for(const p of primes.filter(p=>p>=7&&p>=H.x))assert.equal(exceptions.some(w=>w.p===p),edgeCount(H,p)>0); return {...H,criticalPrime:critical,eventualPrimeOnset:onset,exceptions}; }); process.stdout.write(JSON.stringify({schema:'sah-kill-histogram-v1',source_return:161,gridChecks:checked,T29EdgeChecks:edgeRows,toy:{p:7,wordA:toyA,wordB:toyB,edges:edgeCount(toySupport(toyA),7),L_A:toyL(toyA,7),L_B:toyL(toyB,7)},tiles:certificates,predictions},null,2)+'\n');