10 bool debug(const char *fmt
, ...) {
12 if (getenv("DEBUG")) {
14 vfprintf(stderr
, fmt
, ap
);
23 static char list
[LIMIT
] = "37";
25 static void dump(int iter
, int size
, int idx1
, int idx2
) {
26 if (!debug("iter %d:", iter
))
28 for (int i
= 0; i
< size
; i
++)
30 debug("(%c)", list
[i
]);
32 debug("[%c]", list
[i
]);
34 debug(" %c", list
[i
]);
38 int main(int argc
, char **argv
) {
52 if (goal
> max
- 11) {
53 fprintf(stderr
, "recompile with larger limit to hit goal of %d\n", goal
);
58 dump(iter
++, size
, idx1
, idx2
);
59 size
+= sprintf(list
+ size
, "%d", list
[idx1
] - '0' + list
[idx2
] - '0');
60 idx1
= (list
[idx1
] - '0' + idx1
+ 1) % size
;
61 idx2
= (list
[idx2
] - '0' + idx2
+ 1) % size
;
63 printf("%d...\n", size
);
65 dump(iter
, size
, idx1
, idx2
);
66 printf("score: %.10s\n", list
+ goal
);