In [28]:
from itertools import product
In [26]:
# Part 1
s = ! cat input.txt | tr '\n' ','
l = list(map(int, s[0].split(',')[:-1]))
sum(l)
Out[26]:
In [52]:
# Part 2
ps = [sum(l[: i+1]) for i, v in enumerate(l)]
cl = [(a, b) for ((i, a), (j, b)) in product(iter(enumerate(ps)), repeat=2) if (i != j) and ((a - b) % 525 == 0)]
sorted(map(lambda a: a if a[0] <= a[1] else (a[1], a[0]), cl), key=lambda a: abs(a[0] - a[1]))[0][1]
Out[52]: