def solution(triangle):
answer = 0
# [[0, 7, 0], [0, 3, 8, 0], [0, 8, 1, 0, 0], [0, 2, 7, 4, 4, 0], [0, 4, 5, 2, 6, 5, 0]]
triangle = [[0] + t + [0] for t in triangle]
for i in range(1,len(triangle)):
for j in range(1,i+2):
triangle[i][j] += max(triangle[i-1][j-1],triangle[i-1][j])
answer = max(triangle[-1])
return answer
triangle
:
0 7 0
0 3 8 0
0 8 1 0 0
0 2 7 4 4 0
0 4 5 2 6 5 0
0 7 0
0 10 15 0
0 18 16 15 0
0 20 25 20 19 0
0 24 30 27 26 24 0