Discussion thread for day 13 of the Advent of Code - https://adventofcode.com/2024/day/13
Nice! Lucked out with another easy problem. Having a mathematics background was very helpful.
DO THE MATH!😁
Using a pencil and paper is not violation to Base-A, I believe.
Came here all excited to write about Math but @CoG beat me to it.
I will accept the consolation prize of a substantial amount of bonus sleep.
Solved!
Make Column tool is useful for dataprep.
I was stuck on this for 40 minutes until the solution finally hit me. Once I figured out the way to solve it, it only took a few minutes. Really fun problem though.
This one was fun!
Both methods added brutal did not work for part2
I took the easy way.
I used the system of equations formula:For Ax+By=C Dx+Ey=F then x=(BF-EC) / (BD - EA), y=(FA-CD) / (AE - BD)
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!
Initially thought finally a problem for Optimization tool, even the location optimizer macro. After some unnecessary fiddling, back to basic linear algebra 101 😂
@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 🙄
If only I'd taken a step back at the start and realised it's just maths!
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.
([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
// 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
My solution.
really dusting off the cobwebs in my brain on the math for this one. thanks Khan Academy for the refresher!
Day 13. More in spoiler
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.
Solved. "Just" Algebra and systems of equations.
I used pen and paper first to get my systems of equations sorted out and then did the Alteryx build
Solved.
math problem.😁
Excited to have an easy solve...
Easy in concept, but took me a while to figure out the math needed
Once I brushed off my math skills, it was a lot faster.