Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2023 Day 24 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 24 of the Advent of Code - https://adventofcode.com/2023/day/24

12 REPLIES 12
ScottLewis
9 - Comet

Part 1 is fairly straightforward vector intercept calculation (recommend converting to slope/intercept form and then comparing.)

Part 2 is a linear algebra mess that is probably better solved in Mathematica than Alteryx.

 

Day24.PNG

 

 

One hint for part 2:

Spoiler
Remember how many points it takes to define a line in 3d space. Pick convenient ones and chuck the rest.

 

 

 

Qiu
21 - Polaris
21 - Polaris

Agree. Part 1 is just about a formula about the two lines intersecting point.
For part 2, unfortunetly, Linear Algebra is not my thing 🤣....

gawa
15 - Aurora
15 - Aurora

I did MATH, rather than building WF. No macro solution.

 

Part1

Spoiler
Just solve linear algebra. Not a big deal.

Part2

Spoiler
1) Find the pair of ices having the same velocity component for x, y, z for each
*following explanation will be based on x coordinate, but do the same thing for y and z, too.

2) Calculate the distance between the pair(px1-px2). That distance shall be divisible by (rock_vx)-(vx)
Refer to the below image for better understanding why we can say so.

image.png
3) Find the rock_vx by "Brute Force". For all of possible rock_vx(say 1-1,000), I checked if Mod([px1]-[px2],[rock_vx]-[vx])=0 ,and find the rock_vx having this value is 0 for all of pairs, that will be rock_vx.(In othere word, your task is to find common divisor for all of pairs)

4) Repeat this process for y, and z, then now you have (rock_vx, rocl_vy, rock_vz). Next, we want to know the (rock_px, rock_py, rock_pz), that is the answer for part2.

From here, it might be not the case for you, but my dataset worked this way

5) In my dataset, I fortunately found the ice having vy=rock_vy (or, maybe deliberately by AoC). We know that the rock hit to this ice, so, we can immediately conclude that rock_py shall be py of this ice, otherwise rock and this ice will never hit in the future.
*Imagine, two cars are running straight at the same speed, and toward the same direction in parallel. If their positon are different(one ahead/behind to another), two cars never hit each other, even if one car changes its lane to other lane where another car is running. Only when their position is the same, two cars will hit when trying to change the lane.

6) We have rock_py, so pick up any ice except for one we used in previous step, then do the MATH like; found time T when that ice will hit, and other unknown variables, including rock_px and rock_pz, will be determined automatically.

Overall WF

Spoiler
image.png
estherb47
15 - Aurora
15 - Aurora

Not a pleasant one, and I can't figure out what's wrong with my WF (Answer is too high)

Anyone care to help? @gawa , @Qiu , @ScottLewis ? Workflow attached

 

I've had quite a few "edge case" type data sets, though I can't see how that would be impacting my calculations in a straightforward-ish linear algebra problem.... 

 

Thank you!!

ScottLewis
9 - Comet

@estherb47 

 

You're appending a fileset to itself to create a full match. This works, but it gives you two rows for every pair of input rows (A->B & B->A.) If you don't account for that you're going to double count everything (which you are, checked your workflow with my dataset.)

 

The way I like to correct for this is to do a record ID before the append and then filter on LeftID>RightID. That also removes the self matches (and can be changed to >= if you want to include them.)

estherb47
15 - Aurora
15 - Aurora

@ScottLewis , thank you! I was wondering if that were the problem. Thanks for confirming. I usually like to solve for that with a Generate Rows and then join on the record IDs

Qiu
21 - Polaris
21 - Polaris

@estherb47 
I agree with @ScottLewis  and that is how your result is doubled. 🤣

I usually do is to create another parameter by using Min and Max to pair A and B.
Now it gives correct answer for my input.
and I almost give up on Part 2.

 

2023-12-27 074310.png

gawa
15 - Aurora
15 - Aurora

@estherb47 This is a typical pitfall for me, that is simple one but cannot find it immediately😅

As @Qiu and @ScottLewis  mentioned, I always go with "Appendix Field + Filter" method to create the unique pairs without duplication.

Good luck!

 

AndrewDMerrill
13 - Pulsar

This problem killed me XD I built a Big Num system in Alteryx which handles Multiplication, Division, and Addition (Subtraction is just addition with sign change).

 

Wrote out the formulae to generate a system of equations, then used Alteryx to calculate the solution to the system of equations for single variable. The equations are the same whether solving for x,y, or z so substitute relevant variables and the answer is done. One of the worst possible ways to solve, but I did it, and I'm quite happy about that.

 

Also noticed a cool graph pattern that I couldn't think how to exploit:

Spoiler
Each graph of position vs velocity forms a sort of hour glass shape, where the center point actually gives you the rocks starting position and velocity. I wasn't sure how to capitalize on this, but it is quite cool!
_X graph.png
_Y graph.png
_Z graph.png

Workflow:

Spoiler
Main Workflow:
_Main 1.png
_Main 2.png
Labels