Commit 40eab4bf authored by Taddeus Kroes's avatar Taddeus Kroes

Code cleanup

parent 46eb33ea
#!/usr/bin/env python #!/usr/bin/env python
def combos(A, B): print len(set(a ** b for b in range(2, 101) for a in range(2, 101)))
c = set()
for a in A:
for b in B:
c.add(a ** b)
return sorted(c)
print len(combos(range(2, 101), range(2, 101)))
#!/usr/bin/env python #!/usr/bin/env python
from numpy import array m = [map(int, line.split(',')) for line in open('matrix.txt', 'r').readlines()]
h, w = len(m), len(m[0])
m = array([l.split(',') for l in open('matrix.txt', 'r').readlines()],
dtype=int)
h, w = m.shape
def add(x, y): def add(x, y):
global m global m
p = [] p = []
if x: p.append(m[y, x - 1]) if x: p.append(m[y][x - 1])
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)
for i in range(w+h): for i in xrange(w + h):
for x in range(i + 1): for x in xrange(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)
print m[h - 1, w - 1] print m[h - 1][w - 1]
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