Question: A man needs to go through a train tunnel to reach the other side. He starts running through the tunnel in an effort to reach his destination as soon as possible. When he is 1/4th of the way through the tunnel, he hears the train whistle behind him. Assuming the tunnel is not big enough for him and the train, he has to get out of the tunnel in order to survive. We know that the following conditions are true.
1. If he runs back, he will make it out of the tunnel by a whisker.
2. If he continues running forward, he will still make it out through the other end by a whisker.
What is the speed of the train compared to that of the man?
Answer: This is a simple math and logic question. There is no trickery or hidden assumption here.
We can either do the math and arrive at the solution or just find the solution based on some deductions.
Let T = Speed of train, M = Speed of man, L = Length of the tunnel, D = Distance from train to start of tunnel.
T/M = ?
By observation 1, if he runs back, he will make it out of the tunnel by a whisker. D/T = L/4M – (1)
By observation 2, if he continues running forward, he will still make out through the other end by a whisker.
(D + L)/T = 3L/4M – (2)
Substituting (1) into (2),
L/4M + L/T = 3L/4M
L/T = L/2M
1/T = 1/2M
T/M = 2
Now let’s analyze this question logically. We know that the man and train will be at the start of the tunnel if he runs back. If he runs forward, by the time the train reaches the start of the tunnel, the man would have traveled another 1/4th of the tunnel. That should put him at 1/2 of the tunnel. For the train to meet the man at the end of the tunnel, the train must be travelling at twice the speed of the man since it has to cover twice the distance. Therefore T = 2M.
If you like this post, Please Digg or Stumble this post! As usual, comments are always welcome.If you're looking for some serious preparation for your interviews, I'd recommend this book written by a lead Google interviewer. It has 189 programming questions and solutions: