Tunnel Trouble

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),

Continue Reading Below

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:

Book Cover

3 Responses

  1. Seren says:

    Nice explanation, thanks. I think your notation as it stands is a little confusing though. The emdash looks like a hyphen and makes it look like you are subtracting some constants 1 and 2:
    D/T = L/4M – (1)
    (D + L)/T = 3L/4M – (2)

    A clearer notation might be:
    (1): D/T = L/4M
    (2): (D + L)/T = 3L/4M

    Also to make the final substitution more obvious, (2) could be transformed into:
    (2): D/T + L/T = 3L/4M
    (2): D/T = 3L/4M – L/T

    Thanks again for this fun site!

  2. Shreyas says:

    sorry dint see that the train is behind him my bad 🙂

  3. Shreyas says:

    Dude how will the second observation be (D+L)/T it has to be (D-L)/T cuz D is the distance between the train and the end of the tunnel where the man started initially

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>