|
|
|
|
|
by R_Edward
4252 days ago
|
|
>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?< 17 minutes, if you can stipulate that at the beginning of the problem, the 10 minute and 7 minute people are on opposite sides of the bridge, each paired with one of the other two guys. 18 minutes, if they must all start on the same side of the bridge, but there is no requirement for all of them to end up on the opposite side. This also assumes that person who can cross the bridge in as little as one minute has no problem slowing down to accommodate someone else's slower pace; otherwise there's no real point to trying to share the torch. |
|
It's not a hard puzzle, and I think that it's too easy to try to overthink it to sound smart, like you've done.
The reasonable assumption is that the four people are on one side of the bridge, and you want to have them all on the other side of the bridge.
The simple answer is that the person that takes 1 minute to cross goes with all of the other people, and then brings the torch back for the rest.
So 10 minutes, 1 back, 7 minutes, 1 back, 2 minutes. Total of 20 minutes.
There isn't anything technically specifying that they have to end up on the opposite side of the bridge at the end, but you wouldn't have a situation where someone really wanted to cross the bridge and end up where they started without a torch, and it indicates that the four people have one torch, which implies that they're a party of 4, not 2 groups on opposite sides of the bridge.
I think it's a good question, because it judges the state of the person being interviewed. Are they just scared away by a simple puzzle? Do they come up with some contrivance to try and show off how smart they are? Do they just come up with a practical solution?
Personally, I'd give the practical answer and say 20 minutes, give or take a bit for transferring the torch and turning around. I'd make the assumption that they were all on one side of the bridge and want to go to the other.
When you're given a request to send a request across a network and send a confirmation across the network, you're not going to go and send the some of the requests to the server, and some of the requests to the client, and some of the responses to the server, and some to the client, just because, despite the implied context, you decided that you could make it a bit faster by doing something that didn't make sense because it technically followed the rules.
You probably think your answer is still better, and that's why it's a decent question.