title: highest value path in a 2D list python3
body: <p>okay so I have this problem I have a 2d grid and a player starts in the middle I have to find the highest value path to one of the corners I can but it can't go backwards like this you can only move up down left and right not diagonally </p>
  
  <pre><code>[[0,1,2,4,5],
  [5,4,8,8,2],
  [5,8,x,1,4],
  [7,4,1,2,8],
  [4,4,5,9,2]]
  </code></pre>
  
  <p>if you move up it becomes</p>
  
  <pre><code>[[0,1,2,4,5],
  [5,4,x,8,2]]
  </code></pre>
  
  <p>and you now have a value of 8 any help would be appreciated I'm really struggling with this and its due soon</p>
  
  <p>this is what i have so far building being the data type with room a 2d grid of ints and v being the value so far</p>
  
  <pre><code>    def LT(building,x,y,v):
      print(x,y,v)
      print(building.rooms[x][y].food)
      r=0
      if(not(x==0 and y ==0)):
          if(x-1&gt;=0 and y-1&gt;=0):
              if(building.rooms[x-1][y].food&gt;building.rooms[x][y-1].food):
                  return v + LT(building,x-1, y, v+building.rooms[x-1][y].food)
              else:
                  return v + LT(building, x - 1, y, v + building.rooms[x][y-1].food)
          elif(not(x-1&gt;=0)):
              return v + LT(building, x, y-1, v + building.rooms[x - 1][y].food)
  
          elif (not (y - 1 &gt;= 0)):
              return v + LT(building, x-1, y , v + building.rooms[x - 1][y].food)
  
      return v
  </code></pre>
  
  <p>this is what I have at the moment for the top left corner but its returning a very high number and i cant get to to work </p>