Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 13 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

24 REPLIES 24
DataNath
17 - Castor
17 - Castor

Day 13 done and dusted! I've always struggled with Maths so did have to look up formulae etc, but converted this into BaseA myself. If nothing else this has been a great refresher/lesson in linear equations!

 

Spoiler
Day 13 - Workflow.png
leozhang2work
10 - Fireball
Spoiler
day 13.png

Initially thought finally a problem for Optimization tool, even the location optimizer macro. After some unnecessary fiddling, back to basic linear algebra 101 😂

cgoodman3
14 - Magnetar
14 - Magnetar

@leozhang2work here's how to solve it with the optimisation macro, which I will still count as BaseA as it's a tool installed with Designer 🙄

Spoiler
Part A: Took the brute force approach to solve the equations by generating the rows, but this approach is tool slow for part B
Part B: I knew I could solve it using the optimisation tool, I just need to work out how to shape the data so it would work for the inputs. I've always struggled to know how to do this as I've previously reverted to using manual inputs into the tool but find this is higher risk of typos, plus for today I needed to find a method which would wrap this inside a batch macro.

Screenshot 2024-12-13 111648.png

 

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
Goddenra
8 - Asteroid

If only I'd taken a step back at the start and realised it's just maths!




mark-spain
8 - Asteroid

It took me a while to realise how easy this one actually is 😂

After generating 100 rows each for the button a presses and 100 rows for the button b presses and trying each combination to see which ones worked. I realised that these linear equations can be made much simpler to remove the reliance on Generate Rows. 

Spoiler
AoC 2024 Day 13.png

 


I kept the Generate Rows method in for Part 1, creating a Bool flag to tell me which equations resulted in correct answers: 
([A_x] * a) + ([B_x] * b) = [P_x] && ([A_y] * a) + ([B_y] * [b]) = [P_y]​

and then filtered out where this was false, before calculating the tokens and aggregating: 

[a] * 3 + [b] * 1


For Part 2, I went off in completely the wrong way when I tried to make the X equation and Y equation equal when I multiplied the A and B coordinates by the Prize coordinates. So I got the pen and paper out and worked it out properly and adjusted my formulae. 

// solving for a, multiply prize by b
p_diff = abs(([P_x] * [B_y]) - ([P_y] * [B_x]))

// solving for a, multiply a by b
a_diff = abs(([A_x] * [B_y]) - ([A_y] * [B_x]))

// validate the modulo
Valid Multiple = MOD([p_diff], [a_diff]) = 0

// Calculate a
IF [Valid Multiple] 
THEN [p_diff] / [a_diff]
ELSE NULL()
ENDIF

// Calculate b - watch out for edge cases that don't go into the remainder an equal number of times
IF !IsNull([a]) && MOD(([P_x] - ([A_x] * a)), [B_x]) = 0
THEN ([P_x] - ([A_x] * a)) / [B_x]
ELSE NULL()
ENDIF
Yoshiro_Fujimori
15 - Aurora

My solution.

 

Spoiler
Workflow
workflow.png
Formula
[A] = ([M22]*[X] - [M12]*[Y]) / ([M11]*[M22] - [M12]*[M21])
[B] = ([M11]*[Y] - [M21]*[X]) / ([M11]*[M22] - [M12]*[M21])

 

 

Blake_E
8 - Asteroid

really dusting off the cobwebs in my brain on the math for this one.  thanks Khan Academy for the refresher!

Spoiler
Day13.png
mmontgomery
11 - Bolide
11 - Bolide

Day 13. More in spoiler

Spoiler
P1: Brute force
P2: System of equations by hand then converted it to Alteryx workflow.
94x1+22x2=8400;  
34y1+67y2=5400

x1=y1
x2=y2

94y1+22y2=8400
34y1+67y2=5400

67(94y1+22y2=8400)
22(34y1+67y2=5400)

 629841y1+1474y2=562800
-(748y1+1474y2)=118800

5500y1=444000
y1=80
y2=40

Rinse repeat

Day13.png
Hub119
11 - Bolide
11 - Bolide

Finally getting around to posting this today... took the optimization approach (without using the R tools) to part 1, and then got out the old pen and paper to do some quick math to sort out my formulas for part 2 so my computer wouldn't explode on me...  We've passed the halfway mark... no going back now.

Spoiler
AoC D13 Pic.png
geoff_zath
Alteryx
Alteryx

Spoiler
AoC_2024_day13.png
Labels
Top Solution Authors