/* fold37.c -- independent enumeration of adjacent-kill pairs for T_31 folded by 37. * Same independence discipline as fold31.c: T_23 from the definition, T_31 streamed * by the definitional conditions mod 29 and mod 31, pair count by a position walk over * all 37 * 6,226,553,025 slots asking only "does 37 delete this slot?". * This reproduces reading [6b] of research/a3-08-adjacent-pairs.js, which the file itself * records as coming from a separate detached 2,620 s run with 28 progress lines elided. * Build: clang -O3 -march=native -o fold37 fold37.c */ #include #include #include #include #include #define W23 223092870ULL #define MAXGAP 65536 static double now(void){ struct timespec t; clock_gettime(CLOCK_MONOTONIC,&t); return t.tv_sec+1e-9*t.tv_nsec; } int main(void){ const int qs[] = {2,3,5,7,11,13,17,19,23}; const int P1=29, P2=31, Q=37; double t0=now(); unsigned char *dead = calloc(W23,1); for(int j=0;j<9;j++){ unsigned q=qs[j]; for(uint64_t r=0;r=P1) m-=P1; if(m==0||m==P1-2) continue; uint32_t v=a31[i]+o1_31; if(v>=P2) v-=P2; if(v==0||v==P2-2) continue; uint64_t r=base+T23[i]; if(D==0) first=r; else { uint64_t g=r-prev; if(g>=MAXGAP){fprintf(stderr,"gap too big\n");return 1;} hist[g]++; if(g>G2)G2=g; } prev=r; uint32_t u=a37[i]+o1_37; if(u>=Q) u-=Q; if(D>=cap){fprintf(stderr,"cap\n");return 1;} res[D++]=(uint8_t)u; } } fprintf(stderr," ...outer copy %d/%d, %.2fG slots, %.0fs\n",k2+1,P2,D/1e9,now()-t1); } uint64_t wrap=first+W31-prev; hist[wrap]++; if(wrap>G2)G2=wrap; printf("T31: D = %llu (expect 6226553025), W = %llu, G2 = %llu, wrap = %llu, mean gap %.4f [%.1fs]\n", (unsigned long long)D,(unsigned long long)W31,(unsigned long long)G2,(unsigned long long)wrap,(double)W31/(double)D,now()-t1); t1=now(); const uint32_t cW=(uint32_t)(W31%Q); uint64_t pairs=0,kills=0,runs[64]; memset(runs,0,sizeof(runs)); uint64_t run=0,headRun=0; int seenAlive=0,prevDel=0,firstDel=0; for(int k=0;k