Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>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.



I think the purpose of the puzzle is one of resource management.

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.


"The reasonable assumption is that ..."

Sometimes these questions are explicitly asked to see if the candidate will check the assumptions when there can be more than one, even if one is fairly obvious.


> So 10 minutes, 1 back, 7 minutes, 1 back, 2 minutes. Total of 20 minutes.

21 minutes.


I'm the guy in the interview who says, "Only one person can make it across. The 1 min guy, realizing there is only one torch (and given that one must hold the torch to cross)makes a grab for the torch and runs. The rest get eaten by wolves in the dark".


In the real world, a light source has a useful radius of illumination. This could be exploited. If the useful radius is greater than half the span of the bridge, everyone can cross the bridge in exactly 10 minutes.

If the useful radius of the torch is 25% the bridge length, the bridge can be crossed in 15 minutes.

So the correct answer to the puzzle question is "how much of the bridge does the torch illuminate?"

Then the questioner gets flustered, and you can suggest, "Maybe you should have given them one set of night-vision goggles instead."

If you solve the puzzle as written, you can only be as clever as the puzzle-maker. If you can break the puzzle and then fix it, you must be cleverer.


I don't think that would make the person who's interviewing you very happy.


I have interviewed enough times to know that you can't please everybody. And some interviewers like to assert their dominance during the interview. If they see you as a potential competitor rather than an underling, they won't endorse you.

I once aced an interview brainteaser, and the interviewer actually tried to derail my solution by interrupting and making misleading suggestions. When I finished, he told me that I was the only candidate so far to give the "correct" answer. He was clearly unhappy about it, which confused the heck out of me at the time.

I wasn't supposed to do that. I was supposed to give a half-assed, partially correct answer and let the other guy show off how smart and superior he was, by giving me the "real" answer.

So yes, beating the brainteaser might backfire. If it could, would you still want to work there?


Well if you're stipulating starting positions, the fastest possible would be if the 7 and 10 minute men are on one side, and the 1 and 2 minute men are on the other. Each pair would only have to cross once, passing the torch while they are all on the same side. 10 minutes + 2 minutes for 12 minutes total.


It'll take 17 minutes for all the people to cross if they all start on the same side:

  start: 1,2,7,10|
  1:     7,10|1,2  =  2 minutes
  2:     1,7,10|2  =  1 minute
  3:     1|2,7,10  = 10 minutes
  4:     1,2|7,10  =  2 minutes
  5:     |1,2,7,10 =  2 minutes
             total:  17 minutes





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: