- Decompose a problem into smaller, easier to solve components
- Manipulate and access data within data structures
- Find and use built-in Ruby methods to solve challenges
Create an RPNCalculator
class which can evaluate expressions written in Reverse Polish notation.
It should have an evaluate
instance method which takes as its input a valid RPN expression and returns its evaluation. Your calculator only needs to handle addition, multiplication, and subtraction (not division).
Operators and numbers should be separated by a single space.
For example,
calc = RPNCalculator.new
calc.evaluate('1 2 +') # => 3
calc.evaluate('2 5 *') # => 10
calc.evaluate('50 20 -') # => 30
# The general rule is that 'A B op' is the same as 'A op B'
# i.e., 5 4 - is 5 - 4.
calc.evaluate('70 10 4 + 5 * -') # => 0
- Run the Rspec tests, and then translate at least 3 of the tests into Driver Test Code and include it in the driver code section. If the tests are failing to catch a problem, try writing your own driver test code for it.
- Pseudocode
- Initial Solution
- Refactored Solution
- Reflect
- Sync your changes (push your solution) to Github
- Review