Skip to content

Instantly share code, notes, and snippets.

Created April 22, 2015 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/416006e5062acd65c3fe to your computer and use it in GitHub Desktop.
Save anonymous/416006e5062acd65c3fe to your computer and use it in GitHub Desktop.
alphabet = '@.<>()^+-*/,"[]~'
loops = 10
codeinp = ""
code = []
stack = []
codeinp = input()
for character in codeinp:
if character in alphabet:
code.append(character)
else:
print(character)
i = 0
while i < len(code):
if code[i] == "@":
code.pop(i)
i = 0
elif code[i] == ".":
code.pop(i)
for character in code:
if len(character) == 1:
print(character,end="")
else:
print("[")
i = len(code)
elif code[i] == "<":
code.pop(i)
code.pop(i-1)
i -= 1
elif code[i] == ">":
code.pop(i)
code.pop(i)
elif code[i] == "(":
code.pop(i)
stack.append(ord(code.pop(i-1)))
i -= 1
elif code[i] == ")":
code.pop(i)
stack.append(ord(code.pop(i)))
elif code[i] == "^":
code.pop(i)
code.insert(i,chr(int(stack.pop())))
i += 1
elif code[i] == "+":
code.pop(i)
stack.append(stack.pop() + stack.pop())
elif code[i] == "-":
code.pop(i)
stack.append(stack.pop() - stack.pop())
elif code[i] == "*":
code.pop(i)
stack.append(stack.pop() * stack.pop())
elif code[i] == "/":
code.pop(i)
stack.append(stack.pop() / stack.pop())
elif code[i] == ",":
code.pop(i)
stack.append(ord(input()[0]))
elif code[i] == '"':
code.pop(i)
stack.append(stack[-1])
elif code[i] == "[":
code.pop(i)
code.insert(i,str(loops))
loops += 1
elif code[i] == "]":
code.pop(i)
loops -= 1
i = code.index(str(loops))
code.pop(i)
elif code[i] == "~":
code.pop(i)
i += 1
else:
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment