Files
aoc2025/day02/Notes.md
2025-12-02 17:10:14 +01:00

1.0 KiB

Day 2: Notes

Star 1

  • list of ranges
  • range: (compressed) set of numbers
  • number should be considered iff first half equals second half
    • len(number) % 2 == 0?
      • half(1, number) == half(2, number)?
        • store (maybe for task 2?), add

Star 2

  • based on star 1
  • abstract: pattern recognition in general, not only iff len % 2 == 0, plus variable length
  • sliding window from left to right - but where to stop?
  • possible algorithm:
    • grab 1 digit
    • check other digits
      • if they're all the same, store/add
      • else grab +1 digit and repeat - not for other digits but for other digit groups based on length of grabbed digits
      • optimization: abort if len(grabbed) > len(number) / 2, since nothing can repeat at this point
  • more formalized
    • head and tail - head are grabbed digits, tail are remaining ones
    • break if len(head) > len(tail)/2
    • break if len(tail) % len(head) != 0
    • try to remove head from tail over and over again, break if it fails, otherwise store/add