| about | help | code help+videos | done | prefs |
RPN
"RPN" or "Reverse Polish Notation" was popular in calculators of the 1970s. (Not so much now.) It works like this: Instead of typing "1 + 2", you type "1 2 +". The advantage is that you don't need parentheses. Instead of "(1 + 2) * (3 + 4)", you type "1 2 + 3 4 + *". The idea is that each number gets put on a "stack" of intermediate results. When you see an operator (+, -, *, or /), you take the top two numbers off the stack and apply the operator, and put the result back on the stack. The function RPN, giving a string of numbers and operators (all separated by spaces), should return the numeric value of the expression. RPN('1 2 +') → 3.0 RPN('6 3 /') → 2.0 RPN('6 2 1 + / 2 -') → 0.0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 400 Post-solution available
Copyright Nick Parlante 2017 - privacy