We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 9 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 9 of the Advent of Code - https://adventofcode.com/2024/day/9

23 REPLIES 23
peter_gb
10 - Fireball

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-nine
6,237,075,041,489: what a number!

 

IMG_0266.JPG

 

Spoiler
AoC_9.png

AoC_9_macro.png

 

JeffF
Alteryx
Alteryx
Spoiler
Day09-JeffF.png

Part 1 macro

Day09-JeffF-Part1Macro.png

Part 2 macro

Day09-JeffF-Part2Macro.png

 

Tokimatsu
12 - Quasar

Done.

Spoiler
スクリーンショット 2024-12-10 093833.png
スクリーンショット 2024-12-10 094135.png




Hub119
11 - Bolide
11 - Bolide

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.

Spoiler
AoC D9 Pic.png
ntakeda
12 - Quasar

My solution.

Spoiler
2024-12-10_12h25_23.png2024-12-10_12h25_41.png

  

leozhang2work
10 - Fireball
Spoiler
day 9 - 2.pngday 9.png

Part 2 the shift position of 2 caught me out a bit, took a while to handle the updated space.

leozhang2work
10 - Fireball

@mmontgomery That's quite a list of tools 😁

Samantha_Jayne
Alteryx
Alteryx

Trying to get back in the game! Also upgraded to 24.2, welcome Dark Mode 😁

 

Spoiler
Day 9 - Star 1.png
Samantha Clifton
Alteryx
#alteryxrocks
Carolyn
12 - Quasar
12 - Quasar

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

Spoiler
I split everything into its own cell, threw a Record ID on, and then Joined by Position. 

What initially happened was that I wasn't factoring in when a Record ID was already ahead of a space - I threw on a Count of the non-nulls and then only looked at blanks that came before that number (since if it was after, I didn't care about them)

2024-12-11_13-03-48.png

Part 2 v1

Spoiler
For Part 2, I went back to the data before everything was split. I threw it into an Iterative Macro where I checked if I could move it forward. One of the things that I did was if there were multiple blank spots with 3 spaces, I took the one with the lowest ID, since that's where the disk would move. I think that helped with my run time, compared to what other people's runs took. After each 1 was checked and either moved or left alone, I set my field Checked? to 1.

I repeated for 10k iterations without any intelligent stop condition - just find how many disks I have, and keep repeating, starting from the very last disk and working to the very first disk.

Total run time = 7:20

Macro v1.png

Part 2 v2

Spoiler
As Part 2 was running, I got to thinking about how I knew my disk #2 wasn't going to move because there was no space. I didn't need to wait until check 9,999 to determine that. 

I added a Standard macro inside the Iterative macro. After the Iterative macro is mostly done, I take the lowest Disk ("RecordID") that hadn't been checked yet and saw if there was enough room for it to move up. If the answer was no, I would change the "Checked?" field to 1, which would mean that I don't need to run it through iteration 9,999 anymore. Then, the next iteration would check the next lowest Disk.

If the answer was yes (there is space), I left it alone and rechecked after the next iteration. 

I wasn't brave enough to check multiple Disks at the same time. That probably would've helped materially reduce my run time.

I also modified the Iterative macro to have an intelligent stop condition which was based on when all the Disks have Checked? = 1

Run time = 7:10 and Iterations = 5,075... 10 whole seconds faster!

Macro v2.png

 

Macro v2 Inner.png

 

Goddenra
8 - Asteroid

Part 2 of this bugged me for days, but finally got there once I found the final corner case. Really enjoyed this one!

Labels
Top Solution Authors