18 lines
304 B
Python
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)
|