From 37a85f8df1fb3a0dac50152daabf243316f2d31d Mon Sep 17 00:00:00 2001 From: romangraef Date: Sat, 1 Dec 2018 12:31:26 +0100 Subject: Initial commit --- day1/solve.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 day1/solve.py (limited to 'day1') diff --git a/day1/solve.py b/day1/solve.py new file mode 100644 index 0000000..fda5b7d --- /dev/null +++ b/day1/solve.py @@ -0,0 +1,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) -- cgit