Discussion thread for day 2 of the Advent of Code - https://adventofcode.com/2024/day/2
It's time to use Macro but not Iterative one yet.
Messy solution without a macro!
Updated x2 (Tool Golf/Optimized version V4):
Updated (Tool Golf/Optimized version V3 - elegant)
Updated (Tool Golf/Optimized version V2):
(My Original Solution) No fancy macros from me yet:
Day 2 was a nice case of ugly solutions that work. Considered a batch macro but chose to brute force it rather than fiddle with inputs.
The trick is
Why sleep when you can earn AoC stars after midnight? 😀
My solution!
Is today really the second day?
This one definitely challenged me more than I expected for Day 2. The concepts felt straightforward, but my execution was... not. I found myself reworking the logic several times. I have the feeling there's a more straightforward approach, but my tired brain couldn't find it today. Hoping to revisit this one!
@gawa Your solution is so elegant! Thank you for sharing
no macro. let see how many days challenge can solve without macro
I went down the rabbit hole with part 2!
Ignoring the bad res. Part 1 was simple, but I got caught out where the total number of levels could be different for each record in the real data.Part 2, I spend so long trying something based on what I had done in part one of identifying if each row was an increase or decrease on the previous, going with complex multirows. For example IF Decrease but previous row was an increase, change to increase if the next row - previous row is actually an increase <=3... But my brain wasn't working.In the end went down the batch macro route, but also couldn't work out if I need a batch or iterative, so just hardcoded the logic of skipping layers and calculating if all increasing or all decreasing.
-
Well I feel like the heat turned up a little bit... 😅
I solved it, but it is an uncool workflow.
Tool Golf for Part2 without Macro. Another fun of AoC is refining WF which I believed it was the best at that time.
Used an iterative macro, does not yet deserve the beauty prize. But it works.
lacks versatility
Continue Filter...
With a bit of thinking time I've come up with my attempt at tool golf.
Certainly won't be winning any awards for elegance but work calls and 2 stars = 2 stars. Definitely lured into a false sense of security yesterday!
Took a lot longer than yesterday, but I got there after I gave up refusing to use a macro on Day 2.
IF !IsEmpty([Concat_State]) && Contains([Concat_State], ",") THEN REGEX_Replace([Concat_State], '(\b[^,]+)(?=.*, *\1(?:,|$)), *', '') ELSE [Concat_State] ENDIF​
and the macro:
Part 1 done. Working on Part 2. Boy that's a corker!
Star 2... coming soon...
My Solution is a little bit chaotic and I used Batch macro for Start 2
no shame in copy/paste with AoC imo
Day2
My solution.
Day 2. Struggled without the batch macro for part2 but finally got it.
I have gotten rid of no use tools and I have reorganized my messy workflow. As a result, tools are decreased from 33 to 18.
<deleted>
I was missing a true tool golf solution ... so I had to create one. Here it is:
Solution
part 1 kept it simple and working.
Your V2 is pretty slick @CoG - nicely done!
(I split the asc and desc - but with your carrying over the direction flag you can avoid this)
Thanks to @gawa for your solution. While I took a different approach, I used yours to check my input and determine which specific records were causing me to not get the correct count. I found my issue and am so grateful to have final solved part 2!
It is messy but my solution is attached. Here are screenshots too: