Skip to content

Instantly share code, notes, and snippets.

@zigzackey
Last active March 30, 2016 12:49
Show Gist options
  • Save zigzackey/4d003d45547b3f95971d3a594f83b133 to your computer and use it in GitHub Desktop.
Save zigzackey/4d003d45547b3f95971d3a594f83b133 to your computer and use it in GitHub Desktop.
ope = {"+": lambda a, b: b + a,
"-": lambda a, b: b - a,
"*": lambda a, b: b * a}
stack = []
for c in input().split():
if c in ope:
stack.append(ope[c](stack.pop(), stack.pop()))
else:
stack.append(int(c))
print(stack[-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment