Skip to content

Programming a language

Python script:

with open("input.txt","r") as file:
    input = file.read()
    # print(input)

    st=[0]
    for c in input:
        match c:
            case "-":
                st[-1]-=1
            case "+":
                st[-1]+=1
            case ">":
                st = st[1:len(st)] + st[0:1]
            case "<":
                st = st[-1:len(st)]+st[0:-1]
            case "@":
                st[-1],st[-2] = st[-2],st[-1]
            case ".":
                st.append(st[-1])

    print(''.join([chr(num) for num in st]))