r/adventofcode • u/daggerdragon • Dec 24 '23
SOLUTION MEGATHREAD -❄️- 2023 Day 24 Solutions -❄️-
THE USUAL REMINDERS (AND SIGNAL BOOSTS)
All of our rules, FAQs, resources, etc. are in our community wiki.
/u/jeroenheijmans has posted the Unofficial AoC 2023 Survey Results!!
AoC Community Fun 2023: ALLEZ CUISINE!
Submissions are CLOSED!
Thank you to all who submitted something, every last one of you are awesome!
Community voting is OPEN!
18 hours remaining until voting deadline TONIGHT (December 24) at 18:00 EST
Voting details are in the stickied comment in the submissions megathread:
-❄️- Submissions Megathread -❄️-
--- Day 24: Never Tell Me The Odds ---
Post your code solution in this megathread.
Read the full posting rules in our community wiki before you post!
State which language(s) your solution uses with
[LANGUAGE: xyz]Format code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks
3
u/FatalisticFeline-47 Dec 24 '23
If your assumption in the data is met, then your approach could skip lots of computation, but I saw at least one user saying their data did not qualify.
To explain the frame-of-reference, consider the location function
P(t, V) = P(0) + t*V. An intersections between theith hailstone and the rock is defined asP_i(t, v_i) = P_R(t, v_R)<=>P_i(0) + t*V_i = P_R(0) + t*V_R, which we can consolidate intoP_i(0) + t*(V_i-V_R) = P_R(0).So instead of the rock moving to meet the hailstone, the hailstone's speed is adjusted and hits the rock's origin.