#P2027. BrainFuck
BrainFuck
Description
The execution model is very simple: there is an array of signed -bit integers (range ) and a pointer to a position in this array, which initially points to the first cell.
The character set is also very simple: only + - , . > < [].
| Character | Meaning |
|---|---|
< |
Decrease the memory address pointed to by the pointer by one. |
> |
Increase the memory address pointed to by the pointer by one. |
+ |
Increase the value in the current cell by one. |
- |
Decrease the value in the current cell by one. |
. |
Output the value in the current cell as a character. |
, |
Read one byte from the input buffer into the current cell. If the input buffer is empty, store . |
[ |
While the value in the current cell is not , repeat the statements between it and the matching ], until upon returning to [ the current cell becomes . |
] |
Same as above. |
Input Format
The input consists of several lines; the code may contain comments. The code ends at the first $.
Immediately after the $ comes a space (which does not belong to the input buffer), then the contents of the input buffer, ending with a space and a $.
Output Format
Output the result of executing this code.
write whatever u c ,.,.,.,. $ asdf $
asdf
Hint
For of the testdata, there are no loops.
For another of the testdata, loops have no nesting.
For of the testdata, the program will not access out of bounds, the program will finish within steps, and the input string length is no greater than .
The value of a character in memory is the character’s ASCII code.
Translated by ChatGPT 5
京公网安备 11011102002149号