操脑

From Esolang
Jump to navigation Jump to search

操脑 is a derivative of ReverseFuck but in Chinese. It's created by User:None1, and it is a member of Trivial brainfuck substitution.

It is equivalent to ReverseFuck, which is equivalent to brainfuck. It is also the reverse of 脑操, just like ReverseFuck is the reverse of brainfuck.

Note: In Chinese, 脑 means "brain", and 操 means "fuck", so it gets the perfect name

Commands

操脑 ReverseFuck Brainfuck
十   +           -
一   -           +
,   ,           ,
。   .           .
《   <           >
》   >           <
(   [           ]
)   ]           [ 

Examples

Hello, World!

 一一一一一一一一)《一一一一)《一一《一一一《一一一《一》》》》十(《一《一《十《《一
 )》(》十(《《,《十十十,一一一一一一一,,一一一,《《,》十,》,一一一,十
 十十十十十,十十十十十十十十,《《一,《一一,

Cat program

。),。(

Interpreters

Python

import sys
def nc(code):
    s1=[]
    s2=[]
    matches={}
    tape=[0]*1000000
    for i,j in enumerate(code):
        if j==')':
            s1.append(i)
        if j=='(':
            m=s1.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]=='。':
            tape[p]=ord(sys.stdin.read(1))%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
nc(sys.stdin.read())

Turing completeness

It is Turing complete because brainfuck is.