Bridge Crossing Puzzle
An old classic that still trips people up in interviews. The obvious answer is not the best one.
Problem:
Four friends have to cross a rickety rope bridge at night with one torch; the bridge holds at most two people and cannot be crossed without the torch. They take 1, 2, 5 and 10 minutes to cross; a pair moves at the slower person's pace, and the torch must be carried back after each crossing. The obvious plan - let the 1-minute guy ferry everyone across - takes 19 minutes. Do better.
Solution:
Highlight the part between the * symbols for the answer.
* 17 minutes. Send the slow pair together: 1 and 2 cross (2), 1 returns (3), 5 and 10 cross (13), 2 returns (15), 1 and 2 cross (17). The two slow walkers must share a trip, else they alone burn 15 minutes, and a fast walker must wait on the far side to return the torch, so 1 and 2 cross first; the rest is forced. *
Problem:
Four friends have to cross a rickety rope bridge at night with one torch; the bridge holds at most two people and cannot be crossed without the torch. They take 1, 2, 5 and 10 minutes to cross; a pair moves at the slower person's pace, and the torch must be carried back after each crossing. The obvious plan - let the 1-minute guy ferry everyone across - takes 19 minutes. Do better.
Solution:
Highlight the part between the * symbols for the answer.
* 17 minutes. Send the slow pair together: 1 and 2 cross (2), 1 returns (3), 5 and 10 cross (13), 2 returns (15), 1 and 2 cross (17). The two slow walkers must share a trip, else they alone burn 15 minutes, and a fast walker must wait on the far side to return the torch, so 1 and 2 cross first; the rest is forced. *
I understand the solution, but how do you actually come up with the answer, as in how do you state the problem and work through it?
ReplyDeleteReplying to Anonymous's comment, I understand the solution, but how do you actually come up with the answer - The key is to compare how the two fastest people can shuttle the torch. The slow pair should cross together; otherwise they cost at least 15 minutes by themselves, before the torch returns. Send 1 and 2 first (2), return 1 (1), send 5 and 10 together (10), return 2 (2), then send 1 and 2 (2): 17 minutes. The alternative strategy of having the fastest person escort each slower one takes 19. Comparing those two plans reveals why the fast pair should alternate the returns. (Reply created using AI)
Delete