For this problem, you will write an interpreter for an extremely simple programming language. The language does have a name, but for various, ahem, reasons, we shall call it BF.
A BF program operates on a simple $1$-dimensional array of memory cells; there is a pointer to a "current" memory cell. In "vanilla" BF this array has a size of $30,000$, and each cell is an $8$-bit integer — that is, cells store values in the range $0$ to $255$. Incrementing a cell whose value is $255$ wraps around to $0$; decrementing a cell whose value is $0$ wraps around to $255$. All cells are initially set to $0$, and the pointer initially points to the leftmost cell.
A BF program is a string. Each character can be one of $8$ "commands".
| Command | Description |
|---|---|
> | move the pointer one cell to the right |
< | move the pointer one cell to the left |
+ | increment the current cell by $1$ |
- | decrement the current cell by $1$ |
[ | if the current cell is $0$, jump forward to the command after the matching ] |
] | if the current cell is not $0$, jump back to the matching [ |
. | output the current cell as a character |
, | read one character into the current cell |
You do not need to implement the , command.
You should ignore every character in the BF program except the first $7$ commands listed above. The program ends when there are no more characters to be processed.
Interestingly enough, these commands are powerful enough that a BF program can (given sufficient memory, time, and programming patience) perform any computation that any other programming language can do.
Your interpreter is given a BF program on standard input. It may span multiple lines. The program is terminated by a hash mark #.
You may assume that your interpreter is never given a program that is invalid, that runs unreasonably long (or forever), or that crashes off the left or right end of the array. No input is longer than $10,000$ characters.
Print the output produced by executing the BF program. Do not print any characters other than the ones produced by the program.