Created
March 30, 2016 18:49
-
-
Save zigzackey/4ae20ca01328cfd544b3d4f3d46b7221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def push(x): | |
global stack | |
stack.append(x) | |
def pop(): | |
global stack | |
ret = stack.pop() | |
return ret | |
ope = {"+": lambda a, b: b + a, | |
"-": lambda a, b: b - a, | |
"*": lambda a, b: b * a} | |
if __name__ == '__main__': | |
stack = [] | |
for c in input().split(): | |
if c in ope: | |
push(ope[c](pop(), pop())) | |
else: | |
push(int(c)) | |
print(" ".join(map(str, stack))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment