advent/2018/01.py
Joseph Montanaro d6c1d10fca start 2018
2018-12-05 22:08:41 -08:00

18 lines
304 B
Python

from collections import deque
with open('data/01.txt') as f:
data = deque([int(r) for r in f])
print(f'Part 1:\n{sum(data)}\n')
seen = set()
total = 0
while True:
total += data[0]
if total in seen:
print(f'Part 2:\n{total}')
break
seen.add(total)
data.rotate(-1)