=
Jump to navigation
Jump to search
Commands
= if the thing being assigned is a place:
assign place with value(dec)/place value.
if the thing being assigned is a value:
if the place value assigned recently equals to the first decimal number, jump forward the number of the second decimal number commands. Else, continue running.
Place value doesn't have "+" or "-".
4=+123 +143=-12
if anything is assigned to cell 0, print the ASCII value.
Examples
XKCD Random Number
0=+52
Interpreter
Python
tape={}
def read_tape(x):
if x in tape:
return tape[x]
return 0
import sys
code=sys.stdin.read().split('\n')
ip=0
recent=0
while ip<len(code):
try:
lhs,rhs=code[ip].split('=')
except:
ip+=1
else:
if lhs.isdigit():
if not int(lhs):
if rhs.isdigit():
sys.stdout.write(chr(read_tape(int(rhs))))
else:
sys.stdout.write(chr(int(rhs)))
if rhs.isdigit():
tape[int(lhs)]=read_tape(int(rhs))
else:
tape[int(lhs)]=int(rhs)
recent=int(lhs)
ip+=1
else:
if rhs.isdigit():
val=read_tape(int(rhs))
else:
val=int(rhs)
if val==read_tape(int(lhs)):
ip+=val
else:
ip+=1