Day 17
A very weird one today; many different approaches and eerily easy...
For Part 1, I'm sure most people did a brute force! I couldn't take myself to code a brute force for AoC so I spent some time finding a nicer mathematical solution (which ultimately lost lots of leaderboard places!). A 'smart' brute force solution is uploaded above anyway, and the mathematical way is described here. The brute force above hinges on the fact that the two coordinates, x and y, are independent of each other and hence we can focus only on the y coordinate. This drastically improves runtime. The code just simulates all plausible starting y velocities (you have to decide the bounding box yourself! The minimum value has to be the minimum y coordinate of the target area, and the maximum can just be a few hundred to be sure) and checks to see if it is valid - if so, then the new maximum y position is re-calculated (notice my use of max()). And if the y coordinate falls below the minimum (-75 in my case), then we know the velocity is invalid. I can't find a good way to explain my mathematical approach (because I made a lot of assumptions) so until I manage it, you'll have to stick with the brute force ones :)
A naive brute force Part 2 is also uploaded for now - it may be a good idea to print out t in the main if statement to see it converge. The code is just an expanded form of p1, to account for the x coordinate too.
I'm scared for tomorrow...