9 static int do_debug
= -1;
10 void debug(const char *fmt
, ...) {
13 do_debug
= !!getenv("DEBUG");
16 vfprintf(stderr
, fmt
, ap
);
21 void check(int i
, int *a
, int *b
) {
27 if (snprintf(buf
, sizeof buf
, "0%d", i
) != 7) {
28 printf("invalid input %d\n", i
);
31 for (j
= 1; j
< 7; j
++) {
32 if (buf
[j
] < buf
[j
-1])
34 count
[buf
[j
] - '0']++;
36 for (j
= 0; j
< 10; j
++) {
49 int main(int argc
, char **argv
) {
50 int low
= 158126, high
= 624574;
51 int i
, count1
= 0, count2
= 0, possible
= 0;
54 high
= low
= atoi(argv
[1]);
58 for (i
= low
; i
<= high
; i
++, possible
++)
59 check(i
, &count1
, &count2
);
60 printf("%d / %d possibilities over %d in range\n", count1
, count2
, possible
);