This question already has an answer here:
- Reverse Polish notation 43 answers
Your mission, if you choose to accept it, is to create a stack that can do basic math operations.
Your stack must be able to do basic arithmetic (
+-*/) and must support normal base 10 numbers (
0123456879); numbers will only be one character long.
Programming: Input from stdin will be loaded as a program. After the program has finished running, the contents of the stack will be printed with no spaces in between after the program runs.
Each character in the program does a different thing to the stack:
- A number will push itself
- A math operation will take the top two numbers on the stack and push the output.
Division is shown as a integer if it has
Repeating Decimals are cut off at 2 places:
- You stack must have a length of least 128.
- Your stack must be double/float based.
- No eval-ing!
Scoring: Your score is you byte count with a couple modifiers.
0.9if you include mod (
%) and pow (
0.8if you parse numbers in base 36 (
0.7if you parse strings (each character of the string will be pushed as separate numbers)
105, which will output