You can use D = rt here.

For example, suppose the freight train traveled at r mph for 17.8 hours (because it traveled for 7.8 hrs, then another 10 hrs). Then the diesel train traveled at r - 17.1 mph for 10 hours. We can add their distances because the trains are in the opposite direction:

Solve for r.