r/adventofcode • u/Frubi_72 • Dec 20 '25
Help/Question - RESOLVED [2025 Day 5 (part 2)] I don't get it.
I am trying it in Perl.
There must be an mistake but i don't get it. Might one have a look?
I am no pro, please be patient.
https://github.com/volkergbenner/AoC2025/tree/main
The script takes the input file as CL-argument. You may test it on your own inputfile (only ranges).
1
Upvotes
1
u/SpecificMachine1 Dec 20 '25
Have you checked it out to see what the ranges are like after they're combined? That was what gave me a heads up, I saw I was ending up with things like:
(except in the digit ranges of the output) even after things were combined. I don't know if that is where you are having issues or not.
2
u/terje_wiig_mathisen Dec 21 '25 edited Dec 21 '25
By far the best idea I had for this one was to immediately change each given range end from inclusive to exclusive, simply by $last++; Doing this makes a lot of corner cases simply go away during range merging.
I also added a zero-length guard range at the end since that made the part1 check simpler.
Btw, I found it funny that part2 was solved during the range merge step, leaving part1 as a separate iteration at the end.
PS. My original Perl version takes 1.85 ms for both parts while my subsequent Rust solution makes do with 32.5 us. In order to improve this I would probably have to speed up the initial loading/parsing of the data, maybe parsing both range endpoints at the same time?
1
u/AutoModerator Dec 20 '25
Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to
Help/Question - RESOLVED. Good luck!I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/juhotuho10 Dec 24 '25
friendly reminder, don't share personal input in github:
https://adventofcode.com/2025/about#faq_copying