diff options
| author | romangraef <romangraef@loves.dicksinhisan.us> | 2018-12-01 12:31:26 +0100 |
|---|---|---|
| committer | romangraef <romangraef@loves.dicksinhisan.us> | 2018-12-01 12:31:26 +0100 |
| commit | 37a85f8df1fb3a0dac50152daabf243316f2d31d (patch) | |
| tree | a27140252c0b62561f02ca328e2aa43a4f90dbea /day1 | |
| download | aoc2018-37a85f8df1fb3a0dac50152daabf243316f2d31d.tar.gz aoc2018-37a85f8df1fb3a0dac50152daabf243316f2d31d.tar.bz2 aoc2018-37a85f8df1fb3a0dac50152daabf243316f2d31d.zip | |
Initial commit
Diffstat (limited to 'day1')
| -rw-r--r-- | day1/solve.py | 20 |
1 files changed, 20 insertions, 0 deletions
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) |
