My solutions to 2018's advent of code
Ви не можете вибрати більше 25 тем
Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
1234567891011121314151617 |
- import itertools
-
-
- def first_duplicate(values):
- seen = set()
- for item in values:
- if item in seen:
- return item
- seen.add(item)
- return None
-
-
- with open('data/01.txt', 'r') as file:
- frequencies = list(map(int, file.readlines()))
-
- print(sum(frequencies))
- print(first_duplicate(itertools.accumulate(itertools.cycle(frequencies))))
|