1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00
programming-challenges/challenges/reverse-polish-notation
2023-10-23 23:16:24 +02:00
..
solutions chore: better Prettier config for easier reviews 2023-10-23 23:16:24 +02:00
test feat(solutions): add reverse-polish-notation/c/function 2021-10-12 22:48:23 +02:00
README.md feat(challenges): add single-number 2023-08-21 23:11:08 +02:00

reverse-polish-notation

Created by @theoludwig on 29 September 2020.

Instructions

Your job is to create a calculator which evaluates expressions in Reverse Polish notation (a mathematical notation in which operators follow their operands. It does not need any parentheses as long as each operator has a fixed number of operands).

For example expression 5 3 + (which is equivalent to 5 + 3 in normal notation) should evaluate to 8.

For your convenience, the input is formatted such that a space is provided between every token.

Empty expression should evaluate to 0.

Valid operations are +, -, *, /.

You may assume that there won't be exceptional situations (like stack underflow or division by zero).

All the numbers are integers; you don't need to worry about floating point numbers.

Source

Reverse polish notation - Codewars

Examples

See the test folder for examples of input/output.