Thank you so much for your explanation! I kind of found some clues looking up perp dot products & other vector math things, but this breaks it down very nicely.
I implemented your solution in rust, and part 2 failed by +447,761,194,259 (this was using signed 64-bit integers, i64
). When I changed it to use signed 64 bit floating-point f64
and checked that the solution for x
produces a whole number it worked.
I did run your code as-is in an ipython REPL to check. These were the results:
REPL session
If you're curious to check against my puzzle input, it's here
Thank you again for the back & forth, and for sharing your solution!