Better HN
topnewbestaskshowjobs
Log inSign up

cloudyhug

1 karma · joined Jan 12, 2021 (5y ago) · 2 submissions

Submissions

comment 5y ago · link · parent

It means I actually made a mistake! I understand your solution. :)

comment 5y ago · link · parent

I'll try it. I hope I do not make a stupid mistake.

When the first train has travelled one third of the distance separating it from the other train, the fly will have travelled two thirds of this distance, and the other train one third of the distance, in the opposite way, which means it is exactly the moment at which the fly hits the second train and turns back.

Let d be the initial distance between both trains. Now we are solving almost the same problem (the speeds do not change, and the way the fly travels is irrelevant, the problem is symmetric), the only parameter changing is the distance, now being 2/3 * d.

We can reason the same way ad infinitum and we identify the distance D travelled by the fly is the following:

D = 2/3 d + 2/3 (2/3 d) + ... D = 2/3 d + (2/3)^2 d + (2/3)^3 d + ... D = d * {sum for n from 1 to infinity}{(2/3) ^ n} D = 3d

The fly travels 3 times the distance between the trains before dying.