Fog Creek Software
Discussion Board




railroad bridge

This is a question on railroad bridge. The full question can be found at:
http://techinterview.org/Puzzles/railroadbridge.html
Please let me know if anybody has an answer to this.
Thanks
kms

kms
Saturday, March 20, 2004

Um... I believe the train is twice as fast as the man. Heres why:

If the man can make 1/4 of the tunnel just before the train enters (that is, run back the way he came), then after the same time, he can also be at 1/2 of the tunnel, when the train enters the tunnel.

So: the man can run 1/2 of the tunnel in the same time as the train can do the whole tunnel, ergo the train must be going twice as fast.

whew.

DarenThomas
Monday, March 22, 2004

Well, I solved it using simultaneous equations, but dude ...this was a much faster and cleverer way.
Cheers

kms
Monday, March 22, 2004

thanks, kms.

I did try to set up the equations, but since I hardly ever do math, I was fumbling around - and it just struck me :)

Daren Thomas
Tuesday, March 23, 2004

Hi,

I think the train is 1.5 times faster than the man. (For eg if the man is running at the speed of 100 kmph, the train is going at 150 kmph).

This is how i deduced it:
Let the length of the tunnel be 4 * q (4 quarter units)

I) If the man runs forward, he runs 3q distance before the train gets him.
In that time the train travels  (4q+x) where x is the distance the train was away from the mouth of the tunnel, at the instance the man heard it and started to run forward.


II) If the man runs back, he runs q distance
In that the train travels x distance.

With a couple of guesses I found out that x=1.5 q fits properly.

ie.

When the man runs q (going back) the train travels 1.5q
When the man runs 3q (going forward) the train would travel 4.5q (1.5q + 4q)
q      -> 3q
1.5q ->4.5q


All this is under the assumption that i understood the question properly in the first place :)

Swapnil
Sunday, April 25, 2004

The train is twice as fast as the man.

I used this variables:
A = The length of 1/4 of the tunnel
B = The distance between the train and the tunnel
s = The speed of the train / the speed of the man

As = B
3As = 4A + B

3As = 4A + As
2As = 4A
2s = 4
s = 2

Paul Breeuwsma
Thursday, May 06, 2004

The solution given by Paul is absolutely correct. I would like to make the solution a bit clear.
Let us assume the following things:
The total length of the tunnel = x km
Distance between the tunnel and the train in the beginning = y km
Speed of the man = s
Speed of the train (A multiple of the speed of man)= As
So, our intension is to find A
Now, there are two conditions given in the problem.
1. if the man turns around and runs back the way he came, he will just barely make it out of the tunnel alive before the train hits him.
time taken by the man to cover x/4 km = time taken by the train to cover y km.
=) (x/4)/s = y/As
=) x/4 = y/A
Simplify, y = Ax/4

2. if the man keeps running through the tunnel, he will also just barely make it out of the tunnel alive before the train hits him.
time taken by the man to cover (3x/4) km = time taken by train to cover (x+y) km
=) (3x/4)/s = (x+y)/As
=) (3x/4) = (x+y)/A
=) 3Ax/4 = x+y
replace the value of y from the above equation
=) 3Ax/4 = x + Ax/4
=) 3A/4 = 1+A/4
=) A/2 = 1
=) A = 2    Solution.

-Cheers
Sujan Deb
9810543211

Sujan Deb
Tuesday, May 25, 2004

The train is travelling 1 and 2/3 times the speed of the man. Which isn't very fast for a train, but there you go.

If he runs backwards, he just avoids being splatted by the train, meaning that the train blows it whistle one "man run time" unit away from the start of the bridge.
If he runs forwards, he runs three "man run time" units.
The train also does these three units, plus the one for the 1/4 of the bridge he hd already traversed, plus the one from where it started to the start of the bridge.

Train 5 units
Man 3 units
Time = the same
Train covers 5/3 of the distance of the man in the same time, hence is travelling 5/3 as fast.

Super Fraggle
Sunday, October 10, 2004

Super Fraggle:

From the problem definition, we are told that we don't know how far the train is from the tunnel at the start, so we cannot say it is an equal unit away.

In fact, once you see that the solution is Train Speed = 2 * Man Speed, it becomes apparent that the train started two units away from the mouth of the tunnel (if a unit is 1/4 the length of the tunnel).

Michael Kraack
Monday, October 25, 2004

*  Recent Topics

*  Fog Creek Home