Four People on a Rickety Bridge
Question : Four people need to cross a rickety bridge at night. Unfortunately, they have one torch and the bridge is to dangerous to cross without a torch. The bridge can support only two people at a time. All the people don’t take the same time to cross the bridge. Time for each person : 1 mins, 2 mins, 7 mins and 10 mins. What is the shortest time needed for all four of them to cross the bridge ?
Answer = 17 mins
The initial solution most people will think of is to use the fastest person as an usher to guide everyone across. But it would take longer as 10 + 1 + 7 + 1 + 2 = 21 mins. But can it be the right answer? No. That would make this question too simple even as a warm up question.
Let’s brainstorm a little further. To reduce the amount of time, we should find a way for 10 and 7 to go together as they are the fastest among all these. If they cross together, then we need one of them to come back to get the others. That would not be ideal. How do we get around that? Maybe we can have 1 waiting on the other side to bring the torch back.This brings us closer to the solution. So let’s put all this together.
- 1 and 2 cross the bridge and move to the other side.
- Now 2 comes back with the torch from the other side.
- 7 and 10 cross the bridge and 2 remains to this side only.
- Now 1 comes back with the torch from the other side.
- At last, 1 and 2 crosses the bridge and we are done.
Total time taken = 2 + 2 + 10 + 1 + 2 = 17 mins
This article is contributed by Ayush Govil. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.