A higher resolution is required to access the IDE
- 631
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
Brainfuck is a minimalist programming language consisting of 8 commands. That's all.However it is Turing complete and allows you to make whatever you want, if you are very patient and motivated.
Your goal is to create a fully functional Brainfuck interpreter.
Let see how it works.
The Brainfuck model is composed of three elements:
- An array of S one byte cells initialized to 0, and indexed from 0.
- A pointer initialized to point to the first cell (index 0) of the array.
- A program made up of the 8 valid instructions.
The following are the instructions:
-
-
-
-
-
-
-
-
Note: The
Be careful: A Brainfuck program can contain any characters, that allow the developers to comment their code and to make it more readable. Of course your interpreter must ignore all of these "inactive" characters.
In some cases, errors might be encountered. When this happens you have to stop the execution of the program and print the correct error message from the following list:
- "SYNTAX ERROR" if a
- "POINTER OUT OF BOUNDS" if the pointer position goes below 0 or above S - 1.
- "INCORRECT VALUE" if after an operation the value of a cell becomes negative or higher than 255.
Input
Line 1: Three integers L, S and N for the program line count, the needed array size and the inputs count.
Next L lines: A line of the Brainfuck program.
Next N lines: An integer input to the Brainfuck program.
Next L lines: A line of the Brainfuck program.
Next N lines: An integer input to the Brainfuck program.
Output
The output must be the characters sequence printed (. ) by the Brainfuck program, or the correct error message if a problem is encountered.
Note that the given programs will never try to use. on a value corresponding to no printable ASCII characters.
Note that the given programs will never try to use
Constraints
0 < L ≤ 100
0 ≤ N ≤ 100
0 < S ≤ 100
0 ≤ N ≤ 100
0 < S ≤ 100
Example
Input
1 1 0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+.+.
Output
ABC
A higher resolution is required to access the IDE