Zulip Chat Archive

Stream: general

Topic: Advent Of Code 2025 - Day 2


Alfredo Moreira-Rosa (Dec 06 2025 at 12:47):

Here is my solution for Day 2 of advent of code.
Solution is straigth forward, for each range, compute the possible repeating patterns, then sum them up :

Solution

Alfredo Moreira-Rosa (Dec 06 2025 at 13:24):

This solution is not brute forcing (detecting patterns), but does the opposite.
It generates the possible repeating patterns for a range. Hence the use of the numDigits (equivalent of log10n\log_{10} n).
Meaning it's complexity is :

  • part 1 : O(N(logN))O(\sqrt N*(\log N))
  • part 2 : O(N(logN)2)O(N * (\log N)^2) due to dedup, could be improved using HashSet.

Last updated: Dec 20 2025 at 21:32 UTC