• 77

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Goal

Will has a low IQ. In order to show everyone what he is made of, he decided to write his own programming language. However, his low IQ got the better of him and he implemented the order of operations incorrectly!

From highest to lowest priority, here are the operators and what they mean:
- (Unary): Negation
/: Division
-: Subtraction
*: Multiplication

For example, the statement 6+-3*5 would be interpreted as (6 + (-3)) * 5 because - (Unary) has a higher priority than +, which has a higher priority than *.

Your goal is to evaluate the given expression and output the correct answer with these jumbled order of operations.
Input
A string expression containing the expression you need to evaluate.

The expressions contains only decimal digits and operators. No whitespace or parentheses.
Output
A number representing the result of the expression.
Constraints
1 <= length of expression <= 200
Operations are left-associative.
Example
Input
`1+2`
Output
`3`

A higher resolution is required to access the IDE