Arithmetic expression evaluator
Your task
Evaluate an integer arithmetic expression string containing non-negative integers, single- or multi-letter variable names, the operators + - * /, parentheses, and arbitrary spaces. A dict maps each variable name to an integer value. Standard precedence applies (* / before + -), / is integer division truncated toward zero, and the input is well-formed. Return the integer result.
Examples
eval_with_vars(expr: str, varmap: dict) -> intExample 1
Input
eval_with_vars("a + b * 2", {"a": 3, "b": 4})Output
11