Python max benefit
<p>I have to write a function that computes and returns the maximum benefit 
we can achieve from a base of knowledge which is stored per levels in a list of lists.</p>

<p>To test this function the main is:</p>

<pre><code>if __name__ == "__main__":
  l0 = [[7], [3,8], [8,1,0], [2,7,4,4], [4,5,2,6,5]]
  l1 = [[11], [7,32], [14,14,14], [0,1,2,3], [5,99,1,2,7],
       [0,25,9,45, 54,1], [99,88,77,66,55,44,33]]
&gt;&gt;&gt;30
&gt;&gt;&gt;270
</code></pre>

<p>I tried to start from the bottom to the top, is there any other solution?</p>

<p>You can imagine the list like a tree</p>

<pre><code>   [7]
  [3,8]
 [8,1,0]
[2,7,4,4]
</code></pre>

<p>and so on...
I want to reach the walk that have the max benefit, the weight of the choices is given by the number in the list, I have to maximize my path</p>

<p>I have wrote this solution</p>

<pre><code>def maxpath(listN):
  liv = len(listN) -1
  return calcl(listN,liv)

def calcl(listN,liv):
  if liv == 0:
    return listN[0]
  listN[liv-1] = [(listN[liv-1][i]+listN[liv][i+1],listN[liv-1][i]+listN[liv][i]) \
                [ listN[liv][i] &gt; listN[liv][i+1] ] for i in range(0,liv)]
  return calcl(listN,liv-1)

print(maxpath(l0))
print(maxpath(l1))

#output
[30]
[270]
</code></pre>
