← back to unit
Challenge
# stacks advanced
The Backwards Calculator
This alien calculator hears 3 4 + and answers 7 — numbers pile up, and each symbol grabs the top TWO to combine. 👽
You get space-separated tokens: numbers, +, and *. Run the pile machine and print the final number.
Example:
Input: tokens = "3 4 +"
Output: 7
3 and 4 push onto the pile, then + pops both and pushes their sum, 7.
💡 need a hint?
stk-backwards-calculator.py🔒 given lines are locked — write your code in between
loading...