For part one, was there any faster way than just sorting both lists? (For pt 2, I was able to find the linear solution)
I do these all as inefficiently as possible.
Part 2 slow way
total = a1.each.sum do |x|
x * a2.grep(x).length
end
To regex, or not to regex?
Who am I kidding
do(n't)?\(\)|mul\(([0-9]+),([0-9]+)\)
^ I learned later this is “wrong” but I have been blessed by the input gods ![]()
You re-ally missed an opportunity with the phrasing there. Anyway, here is mine:
(don't\(\)|do\(\)|mul\((\d+),(\d+)\))
Was your theoretical problem not limiting it to three digits? If so I did the same.
haha yeah I think it was supposed to be something like \d{1,3}, but I don’t think it mattered
Advent of Code is open! This year there are just 12 problems scheduled, which should make it a lot more doable to get through the whole challenge by the end of the month! Also, there is no more global leaderboard; it sounds like that was getting impractical due to the popularity of the site and the rise of AI.
This year I’ll challenge myself to use some different and unusual language for each one. I’ll also limit my web searches to official docs and StackOverflow, so that I don’t get help from Google’s AI.
First one...
I’ve reset my private leaderboard; if you want to join again please DM me for the code.
UPDATES
For problem 2 I used PHP.
Among other things I learned that in PHP, "101" can be split into two equal substrings, since "1" == "01" is true ![]()
For problem 3 I used GNU Octave. I got lucky - did not realize that numeric values were floating-point by default, and in fact I was within a factor of 100 of the point at which integer arithmetic stops working well (253).