200

From Esolang
Jump to navigation Jump to search

200 is an esolang invented by User:None1. It is his 200th esolang, and it is again, like his 100th esolang 100BF, a brainfuck equivalent.

Commands

200 BF
202 +
020 -
220 ,
022 .
222 [
000 ]
200 >
002 <

Examples

Hello, World!

202202202202202202202202222200202202202202202202202202002020000200202202202202202202202202022200202202202202202202202202222200202202202202202202202202202202202202002020000200202202202202202022202202202202202202202022022202202202022200202202202202202202202202222200202202202202202002020000200202202202202022020020020020020020020020020020020020022002002002002202202202202202202202202202202202202202202202022200200022202202202022020020020020020020022020020020020020020020020022200200202022

Cat Program

202222220022000

Interpreter

Based on the 100BF interpreter

import sys
def twohundred_bf(code: list):
    s1=[]
    s2=[]
    matches={}
    tape=[0]*1000000
    for i,j in enumerate(code):
        if j=='222':
            s1.append(i)
        if j=='000':
            m=s1.pop()
            matches[m]=i
            matches[i]=m
    cp=0
    p=0
    while cp<len(code):
        if code[cp]=='202':
            tape[p]=(tape[p]+1)%256
        if code[cp]=='020':
            tape[p]=(tape[p]-1)%256
        if code[cp]=='220':
            c=sys.stdin.read(1)
            tape[p]=(ord(c) if c else 0)%256
        if code[cp]=='022':
            print(chr(tape[p]),end='')
        if code[cp]=='002':
            p-=1
        if code[cp]=='200':
            p+=1
        if code[cp]=='222':
            if not tape[p]:
                cp=matches[cp]
        if code[cp]=='000':
            if tape[p]:
                cp=matches[cp]
        cp+=1
ahundred_bf(input().split())