/* sed -ne 's/.*BF: \([^ ]\+\)...$/\1/;T;p' bf_scissor.c | ruby bf.rb */ #include #include #include int main(void) { int t[16], p = 0; memset(t, 0, sizeof(t)); /* 8 < 56 60 10 */ t[p] -= 2; /* BF: -- */ while( t[p] ) /* BF: [ */ { p++; /* BF: > */ t[p] += 4; /* BF: ++++ */ while( t[p] ) /* BF: [ */ { p++; /* BF: > */ t[p] += 7; /* BF: +++++++ */ p++; /* BF: > */ t[p]++; /* BF: + */ p -= 2; /* BF: << */ t[p]--; /* BF: - */ } /* BF: ] */ p--; /* BF: < */ t[p]++; /* BF: + */ } /* BF: ] */ assert(p == 0); assert(t[0] == 0); assert(t[1] == 0); assert(t[2] == 56); assert(t[3] == 8); p += 2; /* BF: >> */ assert(p == 2); assert(t[p] == '8'); putchar(t[p]); /* BF: . */ assert(p == 2); t[p] += 4; /* BF: ++++ */ assert(t[p] == '<'); putchar(t[p]); /* BF: . */ p++; /* BF: > */ assert(p == 3); t[p] += 2; /* BF: ++ */ assert(t[p] == '\n'); putchar(t[p]); /* BF: . */ return 0; }