Practice with programming katas in Python
Robert Martin's Bowling Kata. A scoring engine for 10-pin Bowling.
Develop code to allow a mathematical expression to be converted into a binary tree, which can then be evaluated to calculate the sum of the mathematical expression.
Write code that is unit tested that will:
- Produce the tree nodes necessary to represent the binary tree
- Use anonymous functions for the mathematical operations
- Build a binary tree by parsing the string representing the formula in part A
- Execute the operations and evaluate the tree by calling only the root tree node
- Not use if or switch statements or "new up" objects in objects that are used to define the binary tree. Object used for wiring may use if or switch statements or "new up" objects.
Your code must work with the following:
- 2+4+3 evaluates to 9
- 2+4*3 evaluates to 14
- 2/4*6 evaluates to 3
- 2+4*3+5 evaluates to 19
- 2+4*3-5 evaluates to 9
- 3+45+73*5-9 evaluates to 119
- 3+45+735-9/62+7 evaluates to 132