Calling all Racers for the Alteryx Grand Prix! It's time to rev your engines and race to the stage at Inspire! Sign up here.
alteryx Community

# General Discussions

Discuss any topics that are not product-specific here.

## Advent of Code 2022 Day 11 (BaseA Style)

Alteryx Community Team
15 REPLIES 15
15 - Aurora

Today was the first day that I gave up getting up at 5 am and tried the challenge with a good night's sleep. Before tackling the problem, I looked at the stats of the fastest solvers and saw, that the best approaches from the speed kings range between 1-3h. When reading the problem, I realized what they must have done and decided: Let's go simple. No double iterative macros, no iterative / batch combination. Let's analyze the problem and go for just one iterative - but very manual - non-scaling macro. I will go to hell for it and will definitely come back to it in the future and go for the double iterative + batch macro solution - I simply wasn't in the mood today and treated it like a one-time consulting question: You need to get the answer, no matter how and you need it fast.

Spoiler

Macro

Part 2
I think similar to everyone, I tried to simply increase the data type for part 2 to Int64 and afterward to FixedDecimal 50.0. Obviously, it failed, but it was worth a try. When thinking about it more carefully, I thought about last year: It had to be a mathematical solution, and there had to be a clever way to do it. I did the first iteration for the Monkey 0 on paper and simplified the problem. I spend roughly ten minutes trying an approach that would get rid of my part 1 macro entirely and replace it with a single formula but realized, I'm not JB and still not fully up. Attempt 2 was more successful and required only smaller changes to my part 1 macro - so small, that the whole macro is still exactly the same on the screenshot. For everyone working on part 2 and looking for help here: Take the sample they provide and work through it on paper and look for a mathematical pattern.

16 - Nebula

Too many loops for Part 2!!!

Spoiler
In part 2, it took about 3 minutes for 10,000 loops(certainly, the number of loops is 8 x 10,000 = 80,000 loops).
But the time that took the best ratio is how to solve the overflow problem. As a result, I read the reddit and then finally I went to the route using LCM. And also, I mistook the number of monkey in the inner macro... I missed that I set the number of the loop directly.

Macro for Part 1:
Innter Iterative macro :

Outer Iterative macro

Macro for Part 2:
Inner Iterative Macro

Outer Iterative Macro

17 - Castor

Not pretty today but got there without too much trouble.

Spoiler
Workflow:

Macro:

13 - Pulsar

I initially misunderstood the question's counting mechanism but eventually figured out my mistake(s).

Otherwise, part 1 is not too difficult.

For part 2, I did not realise at first that there was an overflow issue and even went so far as to built and Excel simulator to debug my workflows. Once figured out that it was an overflow issue, then I solved it with a mathematical formula (hint: Smallest Common Multiplier) to reduce the dimension.

My solution involves using 2 iterative macros. On my laptop, it takes ~10min to run... and we are only D11...😂

Spoiler
Main flow

Iterative 1: Go through one monkey at a time. The pink and yellow containers include the logic to solve part 1 or part 2.

Iterative 2: Go through one round at a time. All the extra inputs and outputs are there to help with the debugging...

8 - Asteroid

My parsing is still really ugly. Bummed I worked from 12pm-5am called it a night running in the background for part 2 to finish at 6am.

Spoiler
Main (Need to clean up the parsing)

Macro Wrapper (Rounds)

Macro Inner (Logic)

16 - Nebula

Day 11 done !

I used some help for the mathematics because I couldn't figure it out on my own. Besides that, I built something terribly inefficient using nested iterative macros.

Workflow

Spoiler

Macro 1

Spoiler

Macro 2

Spoiler
8 - Asteroid

Took a bit for P1 to figure out, but framework set up P2 was set. Just needed integer overflow fixed with mod function in spoiler

Spoiler
Mod([Initial_Result],9699690)

.

9 - Comet
Spoiler
WorkflowInner macro - for each Round, each MonkeyOuter Macro - for each RoundPart 2 trick, still preserve divisibility check

Well, got some heads up from others, part 2 become a bit more manageable.

17 - Castor

It's NOT BaseA, but my version of the Abacus can solve part 2 in 20 seconds without a macro.  Now that i've gotten used to it, I find it easier to solve this way than an iterative macro.

Spoiler
To oversimplify, I just used my normal solve and used the VarNum and VarText functions to read and write the data in certain spots. The Generate Rows is pretty cool, it's condition expression is actually being updated in the next formula tool. The VarNum/VarText actually allow data to flow backwards (in a sense).

Workflow:

Generate Rows (It's reading a variable that is being update in the following formula tool).

Some of The VarNum/VarText Formulas:

Labels