DEV Community

Discussion on: How important is math in computer programming?

Collapse
 
ocdanny97 profile image
štrudlokokole

I'm not an experienced dev, but judging by what the task is asking for an output (a simple binary yes/no), this is definitely the most efficient way to come up with the solution. (It honestly didn't even occur to me that you could solve it that way)

However, if the task was also to figure out at what exact second they would meet (or at least be the closest together), maybe a stepping algorythm wouldn't be such a bad idea. For instance, if the difference in distance between the two kangaroos becomes greater after one step, they're never going to meet. However, if the distance shrinks after the first step, the program should loop the steps until both kangaroos meet (distance being zero), or at least monitor when the distance starts increasing again, marking down the step before it started to increase (so we also have the lenght of the shortest distance between them, as well as the exact second that happened)

Hope this all made sense!