-1
我想解決項目歐拉中的問題18。看到這裏,https://projecteuler.net/problem=18。帕斯卡三角形最大路徑
def maxpath(triangle):
p = 0
total = 0
for x in range(0,len(triangle)):
if p + 1 < len(triangle[x]) - 1:
if triangle[x][p+1] > triangle[x][p]:
p += 1
total += triangle[x][p]
return total
給定一個2維列表,它會找到從三角形頂部到底部的最大路徑。有人可以解釋這段代碼有什麼問題嗎?