Question 40371

A beautiful problem..
If you put this on dynamic programming a computer will go crazy..for 30 minutes..

A common sense solution is possible in just one minute..

Now the trains approach velocity is 90+60 = 150 mph
Distance between traing at start = 150 miles
so Time from start to collision = 150/150 = 1 hour
The fly keeps flying at 120 mph for one full hour. 
(Ignore time taken by the fly to turn 180 degrees)
Hence ..how far will it travel?  ...= 120 miles .. Maths is easy..Is n't it?

good luck..