BF is a language that was designed to challenge and amuse programmers. BF uses a simple machine model consisting, besides the program, of:
Character | Spelled as | Meaning |
> | Greater than | Increment the pointer (to point to the next cell to the right). |
< | Less than | Decrement the pointer (to point to the next cell to the left). |
+ | Plus sign | Increment (increase by one) the byte at the pointer. |
- | Minus sign | Decrement (decrease by one) the byte at the pointer. |
. | Dot (period) | Puts the value of the byte at the pointer into the output stream. |
, | Comma | Accept one byte of input - from the input stream - storing its value in the byte at the pointer. |
[ | Left square bracket | Jump forward to the command after the corresponding ‘]’ if the byte at the pointer is zero. |
] | Right square bracket | Jump back to the command after the corresponding ‘[‘ if the byte at the pointer is nonzero. |
Input starts with the number of test cases on a line by itself. Then a number of test cases; each test case is formatted as follows.
Output should be “Case “ then test case number (starting with 1) , a colon, a space followed by the contents of the BF program output stream and a new line after each test case.
<u>3 ,>,>,>,.<.<.<. $ abcde $</u> This is a sample BF program <u>,>++++++[<-------->-],[<+>-]<.</u> That Prints the summation of 2 numbers <u>$ 23 $</u> <u>,>,> ++++[<++++++++>-]<. >++++[<<++++++++>>-]<<.</u> Adds to every cell 8*4=32 and prints 'em in reverse order <u>$ AB $</u>
Case 1: dcba Case 2: 5 Case 3: ba