Let the length of Train A be x meters
Let speed of Train B be y kmph
Relative distance = Relative speed * time taken to cross/overtake
Crossing scenario:
Relative speed of 2 trains = 63 + y
Time taken to cross = 27 sec or 27/3600 hrs
Relative distance between 2 trains = Length of Train A + length of train B = (x + 0.5) km
Therefore, x + 0.5 = (63 + y) * 27 / 3600 ----- (1)
Overtaking scenario:
Relative speed of 2 trains = 63 – y
Time taken to overtake = 162 sec or 162/3600 hrs
Relative distance between 2 trains = x + 0.5
Therefore, x + 0.5 = (63 – y) * 162/3600 --- (2)
From (1) and (2), solve for y.
(63 + y) * 27 = (63 – y) * 162
27y + 162 y = 63*162 – 63 *27
189y = 63 * 135 or y = 45 kmph
Substitute in (2) to get x.
x + 0.5 = (63 – 45) * 162/3600
Or x = 0.31 km or 310 meters
Correct Answer: 310 meters