Discussion thread for day 9 of the Advent of Code - https://adventofcode.com/2024/day/9
first?
There are many optimizations that can be made here to shorten time needed for Part 2 (I have only used a few, but have a V2 that I'm working on). Current workflow runs in ~20 minutes:
V2 (Part 2 runs in ~8 minutes):
It seems like there is opportunity for further optimization, but this is what I have for now.
part1 was simpler than I thought at first glance. I tried to create Iterative macro but I realized it's not needed after 1 hour.
For part2, I just configured the required logic into Iterative Macro. No special trick is applied and it took 11 min.
I suppose there should exist a lot of trick to speed up but cannot come up with it for now.
My solution.
P2 was tough Challenge. My WF run in 9min for P1 and P2.
Solved!
I realized that the logic was incorrect, so I had to remake the workflow that I had created several times.
Part1: No macroI solved it by breaking down the file into rows, reversing the order of free space, and joining them by row position. However, free space is larger than files, the end will be a bit strange, so the key point was how to deal with that. Part 2: It would be a lot of work to break it down row by row, so I calculated the number of files and the free space and stuff them one by one into the free space from the back ID files. There are a total of 10,000 IDs, so I just repeated this 10,000 times. My workflow took 8 min for part1 and 2.
Workflow
Macro
Day9. More in spoiler
Finally finished up with day 9! Part 1 was fine. Explored a few different routes for part 2 and got there after a bit of nonsense.
Possibly my favourite ever runtime and now favourite number I've generated in Alteryx.
Felt good to solve that one, I knew my logic was accurate yet inefficient so just hoped for the best and let it do its thing.Keen to look at all these magical <1hr solutions!
Six trillion two hundred thirty-seven billion seventy-five million forty-one thousand four hundred eighty-nine6,237,075,041,489: what a number!
Part 1 macro
Part 2 macro
Done.
Finally getting around to posting this one. Not too bad once you can decipher what is being asked. I definitely went down quite the long rabbit hole on part 2 before rereading the question and realizing the ask was actually a bit simpler than what I was initially attempting to do.
Part 2 the shift position of 2 caught me out a bit, took a while to handle the updated space.
@mmontgomery That's quite a list of tools 😁
Trying to get back in the game! Also upgraded to 24.2, welcome Dark Mode 😁
Solved! I really enjoyed this one. My Part 2 initially ran in 7:20 and then I spent an hour messing around with it and got it to run in 7:10! 😂
Part 1
Part 2 v1
Part 2 v2
Part 2 of this bugged me for days, but finally got there once I found the final corner case. Really enjoyed this one!
This one was a fun exercise, though I'm unhappy with my runtime for Part 2, and wonder if it can be done without a macro.... Would be a heck of a multi-row formula, and I'll noodle on that for a while.
Took a long time to figure out part 2, but once I did, I got the correct answer on the first try. Which is good because the run time was a very long 2 hours 8 minutes.
Happy Holidays to all!!
This is a bit of a blunt approach, but interesting problem.
I will continue for the second star later if I have time.
Again, only got one part done on this one. Here's my solution: