A b******** program has an implicit byte pointer, called ``the pointer", which is free to move around within an array of 32768 bytes, initially all set to zero. The pointer itself is initialized to point to the beginning of this array.
The b******** programming language consists of seven commands, each of which is represented as a single character. Note: ``Industry standard" b******** actually has eight commands, but for the purposes of this problem one command was intentionally omitted.
COMMAND | OPERATION |
> | Increment the pointer. |
Incrementing a pointer value of 32767 | |
results in a pointer value of 0. | |
< | Decrement the pointer. |
Decrementing a pointer value of 0 | |
results in a pointer value of 32767. | |
+ | Increment the byte at the pointer. |
Incrementing the byte value 255 results | |
in the byte value 0. | |
- | Decrement the byte at the pointer. |
Decrementing the byte value 0 results | |
in the byte value 255. | |
. | Output the character whose ASCII |
value is the byte at the pointer | |
[ | Jump forward past the matching ] if the |
byte at the pointer is zero. | |
] | Jump backward to the matching [ |
unless the byte at the pointer is zero. |
For this problem, you will write a program that reads in, parses and executes a b******** program.
The first line of input contains an integer N
For each b******** program, your program should output the text `PROGRAM #n
3 ++++++++[>+++++++++ % hello-world. <-]>.<+++++[>++++++<-]>-.+++++++.. +++.<++++++++[>>++++<<-]>>.<<++++[> ------<-]>.<++++[>++++++<-]>.+++. ------.--------.>+. end +++[>+++++++[. end %% Print alphabet, A-Z. + + + + + +++++++++++++++++++++> ++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ +< [ >.+<- ] end
PROGRAM #1: Hello World! PROGRAM #2: COMPILE ERROR PROGRAM #3: ABCDEFGHIJKLMNOPQRSTUVWXYZ