10 #define MAX 30000 // educated guess
11 typedef enum State State
;
15 typedef struct state state
;
23 // open-coding based on the input, instead of parsing it...
26 state states
[2][2] = {
27 { { true, true, B
}, { false, false, B
}, },
28 { { true, false, A
}, { true, true, A
}, },
32 #define LIMIT 12861455
33 state states
[6][2] = {
34 { { true, true, B
}, { false, false, B
}, },
35 { { true, false, C
}, { false, true, E
}, },
36 { { true, true, E
}, { false, false, D
}, },
37 { { true, false, A
}, { true, false, A
}, },
38 { { false, true, A
}, { false, true, F
}, },
39 { { true, true, E
}, { true, true, A
}, },
43 int main(int argc
, char **argv
)
47 limit
= atoi (argv
[1]);
54 state
*s
= &states
[S
][tape
[pos
]];
55 if (!tape
[pos
] && s
->write
)
57 else if (tape
[pos
] && !s
->write
)
61 pos
= pos
+ (s
->right
? 1 : -1);
62 if (pos
< 0 || pos
== MAX
) {
63 printf ("still %d ops to perform, out of tape, used %d-%d\n",
72 printf ("checksum is %d\n", sum
);