1) Note that Ping manages to walk 10 metres after the end of the train passes Pong before the end of the train reaches him.
2) The distance between Ping and Pong is then 70 metres.
3) Thus the train has travelled 70m in the time it took Ping to travel 10m and so is going 7 times faster.
4) Call the speed of Ping and Pong 'v', making the speed of the train 7v.
5) At the start, the end of the train is moving towards Pong at 8v (the speed of the train plus the speed of Pong).
6) Similarly, the end of the train is moving towards Ping at 6v (the speed of the train minus the speed of Ping).
7) Let 'p' be the time it takes for the end of the train to reach Pong and 'q' the time it takes for the end of the train to reach Ping.
8) Let 'L' be the length of the train.
9) Speed = distance / time, so 8v = L / p (Pong) and 6v = L / q (Ping)
10) The above two equations can be combined to give a value for q - p of L / 24v.
11) Now, consider again the period from the time that the end of the train passed Pong to the time it reached Ping.
12) The length of this time is clearly equal to q - p.
13) In this time, the train travelled 70m (30 + 40), travelling at a speed of 7v.
14) Speed = distance / time again gives us 7v = 70 / (q-p) or q - p = 10 / v.
15) Putting the two expressions for q - p in 10) and 14) equal to each other gives L / 24v = 10 / v which simplifies to L = 240.