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.

1234567891011121314151617181920
  1. import intsets, math, sequtils, strutils
  2. let input = readFile("data/01.txt").splitLines.map(parseInt)
  3. proc part1(freqs: seq[int]): int =
  4. freqs.sum
  5. proc part2(freqs: seq[int]): int =
  6. var seen = initIntSet()
  7. var talley: int
  8. while true:
  9. for n in freqs:
  10. talley += n
  11. if talley in seen:
  12. return talley
  13. seen.incl(talley)
  14. echo part1(input)
  15. echo part2(input)