UTS Programming Competition 2016 Problem 4
From ProgSoc Wiki
This is a part of the UTS Programming Competition 2016 Problem Set.
Problem 4: Mindmelt
Run time limit: 2 seconds
You are on a quest to create the smallest, Turing-complete language interpreter ever!
Your cute little language is comprised of a mere eight characters, each with a significant meaning.
Conceptually, your language works like this:
- You have a large number of cells in memory (10000 cells ought to be more than sufficient for this problem) and you have an 'active' cell. You may change the active cell using the commands '>' and '<'. You perform operations on the active cell using '+' and '-'.
- You also have input and output. '.' will print the contents of the current cell as an ASCII character, while ',' will read input and place its value into the active cell.
- Finally you have loops. '[' opens the loop and ']' closes it. The loop is like a while loop, where the condition being tested is 'while the active cell is not zero'.
Command Meaning + Add 1 to the active cell - Subtract 1 from the active cell > Move the active cell one step to the right < Move the active cell one step to the left [ Start while loop (while the active cell is non-zero) ] End while loop . Print the active cell as an ASCII character , Read from standard input into the active cell
A single test case.
The first line represents standard input to be read in by the interpreter using the ',' command. This line may be empty i.e. no characters other than an end of line marker.
The second and subsequent lines, if any, represent a stream of characters in the printable ASCII range that are to be interpreted. Your interpreter will process one character at a time, acting upon those characters described above and ignoring all other characters (including whitespace).
Cease execution upon encountering the end-of-file (EOF) marker.
Display the output from executing your Mindmelt program.
HELLO ,.,.,.,.,. please print HELLO
Put your solutions here!