Problem of the Day
A new programming or logic puzzle every Mon-Fri

Reverse Polish Notation

Reverse Polish Notation is an easy way to process order of operations for a calculator on a computer. If you're unfamiliar with it or need a refresher head over to the wikipedia link above.

Today's problem will involve you building your own RPN outputer. You only need to handle the following operations: +-*/(). Here are some sample inputs and outputs.

IN: (3 - 4) x 5
OUT: 3 4 - 5 x

IN: 5 + ((1 + 2) × 4) - 3
OUT: 5 1 2 + 4 × + 3 -

For a bonus output the answer to the equation.

Permalink: http://problemotd.com/problem/reverse-polish-notation/

Comments:

  • There are currently no comments. You can be first!

Content curated by @MaxBurstein