My Advent of Code solutions in Python.
kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code
python
1import fileinput
2from itertools import permutations
3
4SEQ = [int(x) for x in fileinput.input()]
5LEN = 25
6
7for i in range(LEN, len(SEQ)):
8 for x, y in permutations(SEQ[i-LEN:i], 2):
9 if x + y == SEQ[i]:
10 break
11 else:
12 INVALID = SEQ[i]
13 print "Part 1:", INVALID
14 break
15
16for n in range(2, len(SEQ)):
17 tot = 0
18 for i in range(len(SEQ)-n):
19 tot = sum(SEQ[i:i+n])
20 if tot == INVALID:
21 print "Part 2:", min(SEQ[i:i+n]) + max(SEQ[i:i+n])
22