To solve this problem we can treat the speed of the trains, the distance traveled, and the time elapsed as variables:
F = Speed of the freight train
D = speed of the diesel train
X = distanced traveled by the freight train
Y = distance traveled by the diesel train
t = time since the diesel train left the station
To find the distance the trains had gone at any time we would need to multiply their speed by the time elapsed, giving us the equations:


(we use
here because the freight train left the station 8 hours before the diesel train)
Because we know that the trains have travelled the same distance at 12 hours we know the following is true:

Because Y and D are equal we now know that:

By substituting 12 for t we get:
We already know the speed of the Diesel train is 85 km/hour so we can substitute that in for D, giving us:

Simplify to get:

Divide both sides by 20 and and we find our answer:
F = 30
So the speed of the freight train is 30 km/hour