aboutsummaryrefslogtreecommitdiff
path: root/day1/solve.py
blob: fda5b7d4a41d25096de884caf1fa45c621e4d4cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from itertools import cycle

from commons import get_input, remove_empty

seq = list(map(int, remove_empty(get_input(1).split('\n'))))

found = set()

freq = 0
dup = 0
for el in cycle(seq):
    freq += el
    if freq in found:
        dup = freq
        break
    found.add(freq)

if __name__ == '__main__':
    print("first:", sum(seq))
    print("second:", dup)