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

Code cleanup

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