Commit 353fb7ef authored by Taddeus Kroes's avatar Taddeus Kroes

81: Code cleanup.

parent 0f434a50
...@@ -2,6 +2,7 @@ from numpy import array ...@@ -2,6 +2,7 @@ from numpy import array
m = array([l.split(',') for l in open('matrix.txt', 'r').readlines()], m = array([l.split(',') for l in open('matrix.txt', 'r').readlines()],
dtype=int) dtype=int)
h, w = m.shape
def add(x, y): def add(x, y):
global m global m
...@@ -11,11 +12,10 @@ def add(x, y): ...@@ -11,11 +12,10 @@ def add(x, y):
if y: p.append(m[y - 1, x]) if y: p.append(m[y - 1, x])
m[y, x] += min(p) m[y, x] += min(p)
h, w = m.shape
for i in range(w+h): for i in range(w+h):
for x in range(i + 1): for x in range(i + 1):
y = i - x y = i - x
if (x or y) and x < w and y < h: if (x or y) and x < w and y < h:
add(x, y) add(x, y)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment