def Kas(code, inp=""):
    g = 0
    tape = [0]
    ptr = 0
    ip = 0
    input_ptr = 0
    G = {}
    mov = 0
    n = 0
    h1 = 0
    h2 = 0
    If0 = 0
    JMP = 0
    ä = 0
     # list renamed
    κ = 0
    loop = {}
    stack = []
    list0 = []
    á = 0
    Ee = 0
    eE = 0
    flag = 0
    flag2 = 0
    call_stack = []
    reg = [0,0,0,0,0,0,0,0,0,
          0,0,0,0,0,0,0,0,0,
          0,0,0,0,0,0,0,0,0,]
    # ループ対応
    for i, c in enumerate(code):
        if c == "[":
            stack.append(i)
        elif c == "]":
            j = stack.pop()
            loop[i] = j
            loop[j] = i

    while ip < len(code):
        c = code[ip]

        if c == "W":
            ptr += 1
            if ptr == len(tape):
                tape.append(0)

        elif c == "w":
            ptr -= 1
            if ptr < 0:
                raise IndexError("Tape pointer went negative")

        elif c == "V":
            tape[ptr] = (tape[ptr] + 1) % 256

        elif c == "v":
            tape[ptr] = (tape[ptr] - 1) % 256
        elif c == "{":
            if tape[6] == 1:
                call_stack.append(ip)
                ip = G.get("n", ip)
        elif c == "}":
            if tape[6] == 1:
                if call_stack:
                    ip = call_stack.pop()
        elif c == "!":
            if tape[ptr] != 0:
                mov, tape[ptr] = tape[ptr], 0
            else:
                tape[ptr], mov = mov, 0
        elif c == "J":
            ip += JMP - 1
        elif c == "j":
            JMP = G[code[ip-1]]
        elif c == "°":
            mov = 0
        elif c == "#":
            print(" ", end="")
        elif c == "^":
            n = ptr
        elif c == "ㄛ":
            g = (g+1)%3
        elif c == "厂":
            if reg[0] == 1 and reg[2] == 1 :
                if reg[3] == 1:
                    G["α"] = κ
                else:
                    G["β"] = κ
        elif c == "‘":
            if reg[1] == 1:
                ä = 0
                while mov % ä == 0:
                    ä += 1
                h1 += ä
        elif c == "Λ":
            tape[ptr] = (tape[ptr] + tape[n]) % 256
        elif c == "에":
            if flag == 1:
                Ee = (Ee + 1)%256
        elif c == "Ě":
            if flag == 1:
                tape[ptr], list0[eE] = list0[eE], tape[ptr]
        elif c == "&":
            if reg[3] == 1 and reg[4] == 1:
                if g == 0:
                    tape.pop(len(tape))
                elif g == 1:
                    list0.pop(len(list0))
                else:
                    G.pop(code[ip-1])
        elif c == "예":
            if flag == 1:
                eE =  (eE + 1)%len(list0)
        elif c == "⇉":
            if flag2 == 1:
                tape[ptr], tape[n] = tape[n], tape[ptr]
        elif c == "*":
            if flag2 == 1:
                flag2 = 0
            else:
                flag2 = 1
        elif c == "(":
            flag = 1
        elif c == ")":
            flag = 0
        elif c == "λ":
            tape[ptr] = (tape[ptr] - tape[n]) % 256
        elif c == "S":
            if tape[ptr-1] > tape[ptr]:
                Q = tape[ptr-1]
                tape[ptr-1] = tape[ptr]
                tape[ptr] = Q
        elif c == "X":
            print(chr(tape[ptr]), end="")
        elif c == "Q":
            print(tape)
            print("")
        elif c =="ℓ":
            if reg[3] == 0 and reg[4] == 1:
                if g == 0:
                    print(len(tape), end="")
                elif g == 1:
                    print(len(list0), end="")
                else:
                    print(len(G), end="")
        elif c == "q":
            print(reg[5])
            print("")
        elif c == "≫":
            if tape[ptr] < If0:
                ip += 1
        elif c == "➡︎":
            if tape[ptr] != If0:
                ip += 1
        elif c == "ʞ":
            if code[ip-1] in G:
                reg[5] = 1
            else:
                reg[5] = 0
        elif c == "§":
            if reg[3] == 1 and reg[4] == 1:
                list0.append(0)
        elif c == "?":
            If0 = tape[ptr]
        elif c == ".":
            print("")
        elif c == "x":
            if input_ptr < len(inp):
                tape[ptr] = ord(inp[input_ptr])
                input_ptr += 1
            else:
                tape[ptr] = 0
        elif c == "ʍ":
            h1 += 1
        elif c == "M": # 直前の文字をキーに現在地を保存
            G[code[ip-1]] = ptr
        elif c == "m": # 保存した場所へ戻る
            ptr = G.get(code[ip-1], ptr)
        elif c == "Y":
            if ip < 1:
                raise IndexError("どないせーっちゅーねん")
            else:
                G[code[ip-1]] = mov
        elif c == "y":
           if ip < 1:
                raise IndexError("どないせーっちゅーねん")
            else:
                mov = G[code[ip-1]]
        elif c == "˖":
            κ += 1
        elif c == "˗":
            κ -= 1
        elif c == "ª":
            κ *= 64
        elif c == "ʬ":
           h1 = κ
        elif c == "Ŵ":
            h1 = 0
        elif c == "ɥ":
            h2 = (h2 + 1) % 5
        elif c == "ʷ":
            if h2 == 0:
                Cat = lambda x : x * h1
            elif h2 == 1:
                Cat = lambda x : x // h1
            elif h2 == 2:
                Cat = lambda x,y : x + y
            elif h2 == 3:
                Cat = lambda x,y : x - y
            elif h2 == 4:
                Cat = lambda x : x ** h1
        elif c == "ˇ":
            if reg[0] == 1: 
                G["ㄠ"] = ord(code[ip-1])
        elif c == "Δ":
            if ip < 3:
                raise IndexError("どないせーっちゅーねん")
            else:
                reg[((ord(code[ip-1]))%27 - (ord(code[ip-2])%27))] = (reg[ord(code[ip-2]) - ord(code[ip-1])] + 1) % 2
        elif c == "ƛ":
            if h2 == 2:
                G["ㄠ"] = Cat(G["α"],G["β"])
            elif h2 == 3:
                G["ㄠ"] = Cat(G["α"],G["β"])
            else:
                G["ㄠ"] = Cat(G["α"])
        elif c == "L":
            if h2 == 2:
                tape[ptr] = Cat(tape[ptr-1],tape[ptr-2])
            elif h2 == 3:
                tape[ptr] = Cat(tape[ptr-1],tape[ptr-2])
            else:
                tape[ptr] = Cat(tape[ptr])
            
        elif c == "[":
            if tape[ptr] == 0:
                ip = loop[ip]

        elif c == "]":
            if tape[ptr] != 0:
                ip = loop[ip]
        ip += 1
        
code = """
VVVVVVVV[WVVVVVVVVwv]W!w!
WW VVVVVVVV ^ wwΛXλ 
WW vvvvvvvv VVVVV ^ wwΛXλ 
WW vvvvv VVVVVVVVVVVV ^ wwΛXλ
WW vvvvvvvvvvvv VVVVVVVVVVVV ^ wwΛXλ
WW vvvvvvvvvvvv VVVVVVVVVVVVVVV ^ wwΛXλ
"""
Kas(code)
print("")

code = """
VVVVVVVV[WVVVVVVVVwv]W!w!V^
WΛVXwXWWΛVVVVVVVVVVXwwX.WWWΛXWΛVVVVVVVXWWWWΛVVVVVVVVVVVVVVX.
"""
Kas(code)

code = """
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVVVVV XW #
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVVVVVVVVVVVVV XW 
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVVVVVVVV XW 
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVV XW.
"""
Kas(code)
code = """
VW VW ɥɥʷLW LW LW LW Q.
"""
Kas(code)


# # 命令でスペースを入れ、最後に . で改行します
hello_world_code = """
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVVVVV XW #
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVVVVVVVVVVVVV XW 
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVVVVVVVV XW 
VVVVVVVV[ʍv]ʷVLLŴ VVVVVVVVVVVV XW
VVVVVVVV[ʍv]ʷVLLŴ VVVV XW.    
"""

# フィボナッチ数列を計算してテープを表示するコード
fib_code = "VW VW ɥɥʷLW LW LW LW Q"

print("--- HELLO WORLD 実行 ---")
Kas(hello_world_code)
print("--- フィボナッチ数列 実行 ---")
Kas(fib_code)



code = """
VVVVVVVVVV ! AY
VVVVV ! BY
°
Ay [v] ! [ʍv] ʷ VVVVVVV L X #
By W [v] ! [ʍv] ʷ VVVVVVVVVVVVV L X .
"""
Kas(code)

code = """
˖ªʬʷ
VL VVVVVVVV XW
VL VVVVV XW
VL VVVVVVVVVVVV XW
VL VVVVVVVVVVVV XW
VL VVVVVVVVVVVVVVV XW #
VL VVVVVVVVVVVVVVVVVVVVVVV XW
VL VVVVVVVVVVVVVVV XW
VL VVVVVVVVVVVVVVVVVV XW
VL VVVVVVVVVVVV XW
VL VVVV XW.
"""
Kas(code)

code = """
@@Δ H ˇ ㄠy!X @@Δ
@@Δ e ˇ ㄠy!X @@Δ
@@Δ l ˇ ㄠy!X @@Δ
@@Δ l ˇ ㄠy!X @@Δ
@@Δ o ˇ ㄠy!X @@Δ #

@@Δ W ˇ ㄠy!X @@Δ 
@@Δ o ˇ ㄠy!X @@Δ 
@@Δ r ˇ ㄠy!X @@Δ 
@@Δ l ˇ ㄠy!X @@Δ 
@@Δ d ˇ ㄠy!X @@Δ 
"""
Kas(code)
code = """
VW VW ɥɥʷLW LW LW LW Q.
"""
Kas(code)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: