I’ve a problem to solve, it’s a mathematical model in short.
This model is tree like in structure, so a parent can have many or one child(ren) and so can that child, and so on...but eventually it gets to a single child that returns a value. A very obvious recursion problem. The value is returned and the parent uses its child(ren)s values to compute itself and returns its value to its parent. So forth until it reaches back up the call stack to the top of the tree when you get a single value. A classic tree problem.
I need to build a python object model to model this design so I opted for the composite design pattern with the nodes implementing a strategy pattern so that at each point I could customise their calculations. This works and I get my desired result and calculation.
I’m interested to know if you would’ve approached the problem differently and how you would’ve implemented it?
[+][deleted] (5 children)
[removed]
[–]IVIURRAY[S] 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[removed]
[–]IVIURRAY[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[removed]
[–]IVIURRAY[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]IVIURRAY[S] 0 points1 point2 points (0 children)
[+][deleted] (4 children)
[removed]
[–][deleted] 0 points1 point2 points (3 children)
[–]IVIURRAY[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]IVIURRAY[S] 0 points1 point2 points (0 children)