We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Simon says brainfuck

From Esolang
Jump to navigation Jump to search

Simon says brainfuck is an esolang created by User:None1,based on brainfuck, the only difference is that each line in the code should begin with "Simon says: "(without quotes, but with space in the end, case sensitive.), otherwise it will be ignored.

Turing completeness

Simon says brainfuck is of course Turing complete because brainfuck is.

Example Programs

Cat Program

Simon says: +[,.]

Note that the space in the middle is MANDATORY.

Hello World

Simon says: +++++++++[>++++++++<-]>.>++++++++++
Simon says: [>++++++++++<-]>+.+++++++..+++.>++++
Simon says: [>++++++++<-]>.<<<<+++++++++++++++.>>.+++.------.--------.

Interpreters

Python

def bf(code):
    tape=[0]*1000000
    s1=[]
    s2=[]
    matches={}
    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
d=""
while 1:
    try:
        c=input()
    except:
        break
    if c.startswith('Simon says: '):
        d+=c
bf(d)