My solutions to 2018's advent of code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

01.py 377B

1234567891011121314151617
  1. import itertools
  2. def first_duplicate(values):
  3. seen = set()
  4. for item in values:
  5. if item in seen:
  6. return item
  7. seen.add(item)
  8. return None
  9. with open('data/01.txt', 'r') as file:
  10. frequencies = list(map(int, file.readlines()))
  11. print(sum(frequencies))
  12. print(first_duplicate(itertools.accumulate(itertools.cycle(frequencies))))