You are viewing a single comment's thread. Return to all comments →
def find_min_path_sum(M): N = len(M) for i in range(1, N): M[i][0] += M[i-1][0] M[0][i] += M[0][i-1] for i in range(1, N): for j in range(1, N): M[i][j] += min(M[i-1][j], M[i][j-1]) return M[-1][-1] print(find_min_path_sum([list(map(int, input().split())) for _ in range(int(input()))]))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #81: Path sum: two ways
You are viewing a single comment's thread. Return to all comments →