advent/2018/01.py

18 lines
304 B
Python
Raw Normal View History

2018-12-06 06:08:41 +00:00
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)