Last active
July 21, 2021 06:37
-
-
Save igorvanloo/e0785ebf4c7b7df015206548023245c4 to your computer and use it in GitHub Desktop.
Problem 81
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compute(): | |
matrix = [[131, 673, 234, 103,18], | |
[201, 96, 342, 965, 150], | |
[630, 803, 746, 422, 111], | |
[537, 699, 497, 121, 956], | |
[805, 732, 524, 37, 331]] | |
y = len(matrix) | |
x = len(matrix[0]) | |
for i in (range(x)): | |
for j in (range(y)): | |
if i - 1 >= 0 and j - 1 >= 0: | |
temp = min(matrix[i-1][j], matrix[i][j-1]) | |
elif i - 1 >= 0: | |
temp = matrix[i-1][j] | |
elif j - 1 >= 0: | |
temp = matrix[i][j-1] | |
else: | |
temp = 0 | |
matrix[i][j] += temp | |
return matrix[x-1][y-1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment