Given a triangle of numbers, find the maximum total from top to bottom
Example:
6
3 5
9 7 1
4 6 8 4
In this triangle the maximum total is 6 + 5 + 7 + 8 = 26
An element can only be summed with one of the two nearest elements in the next row So the element 3 in row 2 can be summed with 9 and 7, but not with 1
The code will receive an (multidimensional) array as input. The triangle from above would be:
example = [[6],[3,5],[9,7,1],[4,6,8,4]]
You need Python 3.5 or higher in order to run this script
Open terminal and run the following command:
python HellTriangle.py "[[6],[3,5],[9,7,1],[4,6,8,4]]"
Open terminal and run the following command::
python -m unittest -v TestHellTriangle
##Why Python? First of all I'm trying to improve my Python skills since my current main language (the one I use everyday in my job) is Java. Besides that I like the fact that the solution using Python requires only a few lines of code