# Four People on a Rickety Bridge

Four People on a Rickety Bridge

This is one of the frequently asked puzzle in writtern test and interview conntected by top IT companies like Google, Yahoo, Microsoft , Adobe , Syemantec , Thought works , CA, Macafee etc..  The puzzle question and its answer is given below.

Puzzle Question :

The puzzle is Four people need to cross a rickety bridge at night. Unfortunately, they have only one torch and the bridge is too dangerous to cross without one. The bridge is only strong enough to support two people at a time. Not all people take the same time to cross the bridge. Times for each person:  1 min, 2 mins, 7 mins and 10 mins. What is the shortest time needed for all four of them to cross the bridge?

Solution for the above puzzle is 17 minites. As per the puzzle to get everyone across in 17 minutes, we need get the two slowest people across together; otherwise we are wasting too much time. Once we get them across, how do we not make one of them walk back with the flashlight? Just have one of the faster people already there waiting to sprint the flashlight back across.
person A: 1 minute
person B: 2 minutes
person C: 6 minutes
person D: 10 minutes

1. A & B cross.  total time:  2 minutes.

C     || A
D     || B
|| flashlight

2. B comes back. total time:  4 minutes.

C    || A
D    ||
B    ||
flashlight

3. C & D cross.  total time: 14 minutes.

B    || A
|| C
|| D
flashlight

4. A comes back. total time: 15 minutes.

A    || C
B    || D
||
flashlight

5. A & B cross.  total time: 17 minutes.

|| A
|| B
|| C D
flashlight

Another valid solution is to have A bring the flashlight back in step 2.

Q*** 10 10 2 1***    Sol- 17
Q*** 10 9 2 1 ***    Sol- 17
Q*** 10 7 2 1 ***    Sol- 17
Q*** 10 7 2 1 ***    Sol- 17
Q*** 10 6 2 1 ***    Sol- 17
Q*** 10 5 2 1 ***    Sol- 17
Q*** 10 4 2 1 ***    Sol- 17
Q*** 10 3 2 1 ***    Sol- 17
Q*** 10 2 2 1 ***    Sol- 17
**Quick Sol**- Suppose a,b,c,d are the take time one can cross the bridge such that a>b>c>d or a>b=c>d or a=b>c>d or a=b=c>d or a=b=c=d
Genreric Sol- a+3*c+d (independent of b. :) )