Advent of Code 2024 Day 22 (BaseA Style)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Discussion thread for day 22 of the Advent of Code - https://adventofcode.com/2024/day/22
- Labels:
- Advent of Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Good break from Day 21. Pretty much just brute force (just need to read thoroughly to ensure that all logic is captured):
Part 2: I modified the first macro to output all evolutions of price for each buyer, generating about 4M records. Multi-Row Formula Tool for the win here. We can use it to calculate the price change, then another one to generate all sequences of 4 consecutive price changes, then index all sequences so that we can isolate only the first occurrence of each sequence for each buyer. From there, we just need to filter off later occurrences and Summarize to identify the total price/# of bananas we can expect to trade for each sequence. Identify the maximum value for the answer!
Main Workflow:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
A nice clean day after a dirty awful yesterday in which I left my workflow running overnight and came back to a finished not the answer.
This one highlights the things Alteryx is good at. Multi-row formulas and summation allow you to shortcut things that most (other) programming languages would find syntactically complicated.
Generation of secret numbers is a clean iterative macro case. Shows off how you should make things like the number of steps an input to make it easier to find the terminal condition and so you don't have to go in and out of the macro for testing.
Part 2 macro modification was just adding a third output that kicked every row rather than just the last one and putting on an ID before sending it into the macro. At this point I should really just be in the habit of doing that anyway in case part 2 needs it. RowID passing through the macro is pretty low cost.
Part 2 logic is interesting. Don't often get to stack two multi row formulas followed by two summations. Here they are calc change, calc sequence, Find first sequence and summarize price by sequence. Then you just sort and you're done in time for tea.
If you wanted to get fancy you could go straight to sequence by embedding the definition of change at each step of the sequence formula but the result would be a case study in how not to write formulas.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Solved!
The question was difficult to understand, but today is straightforward!
For part 2, I can easily find the answer by generating patterns with the Multi-Row Formula tool and summarize the number of bananas for each pattern. Note that a pattern may match multiple times for each buyer, but this is only used for the first pattern.
macro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This was a breath of fresh air, besides me spending an hour troubleshooting the fact that I only ran 1,999 iterations instead of 2,000 after reworking for P2 😅
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It’s not a particularly difficult problem as long as we correctly understand the problem statement.
I struggled a bit to fully grasp the problem statement, but for P1, I followed the instructions, created the formula in the Formula Tool, and ran the loop 2000 times to get the answer.
For P2, I used a multi-row formula tool to calculate the patterns and aggregated the first digit of the price that matched the pattern for each record. Initially, I overlooked the part about "the first price that matches the pattern" and ended up confused when my answers didn’t match.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Day 22. More in spoiler
P2: Take ones column for each row of P1 I-Macro and output it. Then second macro to get pairings of four by using range of iteration +1 to interation +4. Group the categories and sum
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Finally a chill day
