r/adventofcode • u/Conceptizual • 1d ago
Past Event Solutions [2021 Day 19] Finally solved beacons after five years :’)
I restarted this for probably the fifth time (but maybe third serious time) last night and stayed up until 4:30AM working on it, drawing lots of pictures. I am not a better programmer at 3:00AM and this is probably the first/most hand written code I’ve done since spring. I was a little worried I’d forget everything I was doing if I went to bed but I woke up three hours later and found the last bug. 🥹 part 2 was really easy except I printed the most recent distance instead of the longest distance and also tried to find the furthest apart beacons instead of scanners. That was easily fixed by reading/trying the sample.
4
u/AustinVelonaut 1d ago
I remember that problem! That seems to be a common occurrence with me during AoC: I'll go to sleep not having solved something, and my subconscious works on it and hands me the solution in the morning.
3
u/DelightfulCodeWeasel 1d ago
Huge effort, well done!
Nothing quite as satisfying as bagging your white whale.
2
u/careyi4 1d ago
Well done, that’s a hard problem, I remember it breaking my brain when I did it
2
u/terje_wiig_mathisen 1d ago
Well done for not giving up!
I remember the problem, it was during the final week of an internal corporate leaderboard competition.
I was lucky enough that the first approach I tried (fingerprinting scanners by the set of squared distances between the beacons it had detected) worked. The idea is somewhat similar to the SIFT algorithm used by all automatic panorama stitchers, except simpler because it does not need to be "Scale-Invariant".
Looking at my 5 year old code, I realized that I have not written any Rust versions for this year, so that's something I can look forward to after we finish this year.
My Perl code runs in half a second, it was the first day that year that I needed 2+ hours to find the solution, I was obviously quite happy because the code still contains a bunch of debug printf() statements that I didn't subsequently cleanup!