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

21 REPLIES 21
PangHC
12 - Quasar

first?

Spoiler
part1: 
split to the step accordingly then create a freeID in ascend and fileID in descend. verified if the positionID will be smaller.

part2:
use data given before split to the line. (keep the data size, to easier to compare later)
check one by one from bottom, if size is enough, position is earlier.
generate another rows if free size is larger.

loop for 10k iteration, and take 40 mins to run it
Screenshot 2024-12-09 143011.pngScreenshot 2024-12-09 142955.png
CoG
14 - Magnetar

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:

 

Spoiler
A lot of joins and data manipulation, but fairly straight forward. The optimization I used here (for part 2) is to exclude records that are on the right and no longer being considered or so far to the left that no free space exists to move anything else to. Keeping these records does nothing for the calculation but expend memory.
Main.pngIterative Macro (Part 2 - File Manager):
File Manager.png

V2 (Part 2 runs in ~8 minutes):

Spoiler
Primary Optimization: switched to using pre-tokenized data, unlike Part 1. Part 2 data now looks like:
File DataFile Size
05
.2
13
21

Main V2.png

New iterative macro:
File Manager V2.png

It seems like there is opportunity for further optimization, but this is what I have for now.

 

gawa
16 - Nebula
16 - Nebula

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.

 

Yoshiro_Fujimori
15 - Aurora
15 - Aurora

My solution.

 

Spoiler
Part1
Part1_workflow.png
Part2 workflow
The approach for Part 2 is different from Part 1. (I tried, but could not find the way.)
Not sophisticated (it took 48:47 minutes), but it worked anyway.
Part2_workflow.png
Part2 macro
Part2_macro.png
DaisukeTsuchiya
14 - Magnetar
14 - Magnetar

P2 was tough Challenge. My WF run in 9min for P1 and P2.

Spoiler
P1 is no macro. P2 uses itteration macro.
スクリーンショット 2024-12-10 001347.pngスクリーンショット 2024-12-10 001445.png



AkimasaKajitani
17 - Castor
17 - Castor

Solved!

 

I realized that the logic was incorrect, so I had to remake the workflow that I had created several times.

Spoiler
AoC_2024_09_02.png


Part1: No macro
I 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.

AoC_2024_09_03.png

The point is that after the files are moved, there is continuous free space, so if you don't combine it well, you won't be able to pack the files as you intended. This is the last thing I noticed, and I ended up having to recreate the macro I created at the beginning (at first I thought it would be enough to just keep the free space in a loop, but in the end it turned out that I can't combine continuous free space unless I also have the file part).

 

geoff_zath
Alteryx
Alteryx

Workflow

Spoiler
AoC_2024_day9.png

Macro

Spoiler
AoC_2024_day9_macro.png
mmontgomery
11 - Bolide
11 - Bolide

Day9. More in spoiler

Spoiler
P1 was broken into a few steps: 1 was to convert the disk map into ID number and order. 2 was to move the file blocks and I did it without a macro. I wasn't sure if ID number 10 was treated as a number in one slot or broken over two slots. Fortunately I was able to figure out that answer quick

P2 was to build the macro to make sure an entire block could move left if the last item of the block could move over. Brute forced it and it took 45 minutesP2_Macro_P2.pngP2_Macro_P1.pngMap_Macro.pngDay9_workflow2.pngDay9_workflow1.png
DataNath
17 - Castor
17 - Castor

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.

 

Spoiler
Day 9 - Workflow.png


Day 9 - Iterator.png

 

Labels
Top Solution Authors