脑子爆掉
Jump to navigation
Jump to search
脑子爆掉 is a Chinesified Trivial brainfuck substitution by User:PrySigneToFry.
Syntax
| 脑子爆掉 | brainfuck |
|---|---|
| 左 | < |
| 右 | > |
| 上 | + |
| 下 | - |
| 读 | , |
| 写 | . |
| 始 | [ |
| 终 | ] |
Programs
Hello, World!
上上上上上上上上
始
下右上上上上上上上上左
终
右上上上上上上上上写
左上上上上上
始
下右上上上上上左
终右上上上上写
上上上上上上上写
写
上上上写
左上上上上上上上上
始
下右下下下下下下下下左
终
右下下下写
左上上上
始
下右下下下左
终
右下下下写
左上上上上上上上上上
始
下右上上上上上上上上上左
终
右上上上上上上写
下下下下下下下下写
上上上写
下下下下下下写
下下下下下下下下写
左上上上上上上上上
始
下右下下下下下下下下左
终
右下下下写
左
A+B Problem
读左读读 始右上左下终 上上上上上上始右下下下下下下下下左下终右 写
Interpreter in Python
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]=='读':
c=sys.stdin.read(1)
tape[p]=(ord(c) if c else 0)%256
if code[cp]=='写':
print(chr(tape[p]),end='')
if code[cp]=='左':
p-=1
if code[cp]=='右':
p+=1
if code[cp]=='始':
if not tape[p]:
cp=matches[cp]
if code[cp]=='终':
if tape[p]:
cp=matches[cp]
cp+=1
nzbd(sys.stdin.read())
Turing completeness
It is Turing Complete 'cause brainfuck is. (Or, this language is based on brainfuck.)