My solutions to 2018's advent of code
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
Tento repozitář je archivovaný. Můžete prohlížet soubory, klonovat, ale nemůžete nahrávat a vytvářet nové úkoly a požadavky na natažení.

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))))