Discussion thread for day 5 of the Advent of Code - https://adventofcode.com/2025/day/5
Ok part 1 was easy... now part 2 I'll have to figure out after I get some sleep.
Appreciate the consistent quality of this year's puzzles. Wonder if cutting down also means focusing more on each one.
Also appreciate that work from home tomorrow means I get to do this one on time rather than the next day. Have missed the race.
Part 1 of today was straightforward.
Part 2 caught me for a minute.
Final
Okay this one was kind of cool. In some ways easier than previous days, but it was different in the way you needed to solve it and I like that.
Here's my solution:
Here's the narrative:
Solved !!
Solved.
A lot of easy problems this year. I enjoyed the algorithmic approach that could be optimized in Part 2!
Happy Solving!
Started out by way overcomplicating this, thinking back to AoC 2021 where you need to account for overlapping cubes in 3 dimensional space and building in some set math (I blame the Whiskey Advent Calendar I am pairing with this event this year 🥃)... only to eventually realize I could simplify this big time by just sorting my ID ranges in part 2 and just build groups adjusting the range bounds as I go...
Another challenge I was able to complete in 1 sitting, taking just over 1 hour in total for both parts! I did not find this puzzle particularly challenging, but part 2 had it's *specialties*. Anyways, it's back to waiting for another puzzle!
My Solution:
My Reflection:
Is it just me who first applied the Generate Rows tool for part2 and as soon as run WF, endless number of rows were being generated? Thanks to Algorithm.
Today's AoC is fun.
At first, I tried using a "Generate Rows" tool, but realized it would run forever, so I rebuilt my workflow.For Part 1, I created combinations of IDs and ranges by appending tool, and then checked if the ID was within the range.
For Part 2, I sorted the ranges by their start value and then merged any that overlapped.
My solution.
I couldn't come up with a good solution, and it took longer than I thought it would. Everyone else has created simple solutions, so I'll take another look at them.
It was a process of trial and error using Spatial tools and Batch Macros. I needed several breakthroughs to arrive at the correct answer.
Getting difficult...
max(start1, start2) <= min(end1, end2)
Sneaky example which pushed me down the Generate Rows route initially. Lesson learned to look at the data first!
I used a batch macro for part 1 - probably not necessary. Solved part 2 without macro.
Another 2 stars! Certainly getting tougher than day one, but managing to keep the pace up so far.
Part 11) Today's input data actually had two separate lists - the list of fresh ranges and the list of ingredients. To get started, I separated the two lists by filtering to records containing a "-", as these were the ranges. With the fresh ranges identified, I could then use the "-" delimiter to parse the upper and lower bounds into separate rows, before renaming and changing the new columns' data types to numeric.
2) Next I appended all the ingredients onto all the ranges. Yes this grew the data but we only had a few hundred rows of data each side, so light work for Alteryx. With the appended data I could then filter to the cases where the ingredient ID, fell within the upper and lower bounds.
3) The steps so far, will likely have resulted in some ingredients being approved twice if they appeared in more than one cell range. To get around this I did a count distinct on the ingredients, to get my final answer.
Part 2For part two, we aren't interested in the ingredients list at all. All we need to examine is the fresh ranges. With this in mind, the first step for part two can be the same as step on from above. 1) Once we have the list of ranges, the next step is to simplify them. To tackle this, I started by sorting the Lower and Upper Bounds in ascending order. This then allowed me to keep track of the "Rolling Maximum ID". What I mean by this, is that at any point, I would know what the previous, highest ID value had been. i.e:
As you will notice, we can now identify which lines have already been accounted for. The upper bound in Row 4, is lower than the Rolling maximum ID meaning that all the records represented by the range 21-25, have previously been seen. Therefore, we can remove this row from the process.
2) You will have likely noticed, that we still need to deal with the overlap, between record 1 & 2. The way I approached this, was to update the Lower Bound, so that the two groups, no longer overlapped.
The formula to account for the above is actually quite simple. To update the lower bound we just need to take the maximum between the Lower Bound and the (Rolling Maximum ID + 1). Once the lower bound is updated, its easy enough to count the number of IDs within each range. The count is simply the Upper Bound - Updated Lower Bound + 1 (the plus one is to account for the fact that the ranges are inclusive).
3) The final step is to simply sum all of the counts to find out the total number of fresh IDs!
Thank god for...
Looks lik I did the same/similar to others for part 1.
Part 2 just isn't working for me. I'll have to come back to it later.
Was tempted to be lazy and brute force the answer on Pt 2, but since the explanation "I burnt my work computer to a crisp looking for fresh ingredients for elves at the north pole" probably wouldn't fly at my company - I decided a more clever solution was needed.
@gawa after blowing up my computer doing this very thing earlier in the year, I now know better... at least most of the time 🤣
Day 5
Easy enough to brake your computer into One Piece...
Part 1 took me 10-15 minutes. Part 2 however... we won't talk about that.
I was beating my head against a wall trying to figure out where my logic was wrong on the second star......it wasn't. I just didn't enter the number right.
Brute-forced part 1, but had to get more efficient for part 2! I have never used the Int64 data type so much in my entire life 😅
I added a non macro solution( and Make Group solution).
love to see other new ideas to solve the question.
part2:1st method, split the range.1. update start=[row-1:end], if start is less then end.2. update end=start, if end is less then start3. reduce end-1, if end equal to [row+1:start] <-this take me an hours4. removed triplicate where end is less than start) <- this take me another 2 hours.PS: I sure it is not cover all situation. but it solved.
A very nice day 5! Took me a little to realise the quirks of part 2 and ended up creating a disgraceful Multi-Row Formula expression but hey, 2 stars = 2 stars.
Part 2 almost broke me (and by "me" I mean the computer) until I realized
Part 2 is always the brain twist,