Advent of Code 2024 Day 13 (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 13 of the Advent of Code - https://adventofcode.com/2024/day/13
- Labels:
- Advent of Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Initially thought finally a problem for Optimization tool, even the location optimizer macro. After some unnecessary fiddling, back to basic linear algebra 101 😂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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 🙄
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.
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
- 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
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
My solution.
Formula
[A] = ([M22]*[X] - [M12]*[Y]) / ([M11]*[M22] - [M12]*[M21])
[B] = ([M11]*[Y] - [M21]*[X]) / ([M11]*[M22] - [M12]*[M21])
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
really dusting off the cobwebs in my brain on the math for this one. thanks Khan Academy for the refresher!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Day 13. More in spoiler
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
 
