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
# Simple Shunting-Yard solution | |
# | |
# Given a math expression, parse and evaluate | |
# the expression | |
# | |
# E.g '2+1' => 3, 8/2*4+1 => 17, 2+(1*2) = 4, ((2+4)/2*7) => 21 | |
# | |
def parse_math_expression(exp): | |
PRECENDENCE = { | |
')': 3, |