掉爆子脑
Jump to navigation
Jump to search
掉爆子脑 is an Esolang that designed and implemented by PSTF.
It is reversed version of 脑子爆掉.
Command Table
This Esolang 脑子爆掉 Brainfuck 右 左 < 左 右 > 下 上 ^ 上 下 v 写 读 , 读 写 . 终 始 [ 始 终 ]
Example
Cat program
写终读写始
Interpreters
import sys
def nzbd(code):
s=[]
matches={}
tape=[0]*1000000
for i,j in enumerate(code):
if j=='终':
s.append(i)
if j=='始':
m=s.pop()
matches[m]=i
matches[i]=m
cp=0
p=0
while cp<len(code):
if code[cp]=='上':
tape[p]=(tape[p]-1)%256
if code[cp]=='下':
tape[p]=(tape[p]+1)%256
if code[cp]=='读':
print(chr(tape[p]),end='')
if code[cp]=='写':
c=sys.stdin.read(1)
tape[p]=(ord(c) if c else 0)%256
if code[cp]=='左':
p+=1
if code[cp]=='右':
p-=1
if code[cp]=='始':
if tape[p]:
cp=matches[cp]
if code[cp]=='终':
if not tape[p]:
cp=matches[cp]
cp+=1
nzbd(sys.stdin.read())