Ella Kaye - Advent of Code 2023 wrap up #10
Replies: 1 comment 1 reply
-
Thanks for a great resource! Long after the event I did come up with a solution to Day 24 Part 2 in base R based on solving the system of equations. All the work is in rearranging the equations. Must sign up for the R leaderboard next year. Day 24 Part 2 Maths: Calculation of a system of equations Equate x, y and z values and then rearrange in t We only need to solve for x and y to start with From the above equation, subtract same equation but for hailstone j - This eliminates the quadratic terms X0.B & Y0.A Rearranges to the final linear equation in 4 variables Can use data from 4 or 5 hailstones to generate 4 simultaneous linear equations suitable for the solve function Then to solve for z now knowing A, B, X0 & Y0 Linear equation in 2 variables use 2 hailstones to make 2 equations and solve #Code for part 2 hailstone positions in dataframe p and velocities in dataframe q AA=NULL EE=matrix(c(1,1,(X0-p$x[1])/(q$x[1]-A),(X0-p$x[2])/(q$x[2]-A)),ncol=2) Z0=solve(EE,FF)[1] format(X0+Y0+Z0,scientific=F) |
Beta Was this translation helpful? Give feedback.
-
Ella Kaye - Advent of Code 2023 wrap up
Reflections on participating in this seasonal coding challenge.
https://ellakaye.co.uk/posts/2023-12-30_advent-of-code-2023/
Beta Was this translation helpful? Give feedback.
All reactions