fn simulate<const N: usize>(input: &([i32; 4], Vec<(Point, i32)>)) -> u32
Expand description
Simulates a rope of arbitrary length.
The head knot always moves according the instructions from the problem input. Remaining knots move according to their delta from the head (2nd knot) or the previous knot (3rd and subsequent knots).
Using const generics for the rope length allows the compiler to optimize the loop and speeds things up by about 40%.