techInterview
Answers to technical interview questions - accepting donations for dogs

 
home
faq
reading
feedback
discuss
archive
fogcreek
bug tracking
pets in ny
petfinder



*new* techInterview bible


thank your brain
save a dog's life




 

easy river crossing  aha:!

three cannibals and three anthropologists have to cross a river. the boat they have is only big enough for two people. if at any point in time there are more cannibals on one side of the river than anthropologists, the cannibals will eat them. what plan can the anthropologists use for crossing the river so they don't get eaten?

remember! the boat can't cross the river by itself, someone has to be in it to row it across.

a much harder river crossing problem will appear later this week.

A - anthropologist
C - cannibal
++ - boat
 
        river
AAA |============|
    |++          |
CCC |============|
 
need to make it
        river
    |============| AAA
    |          ++|
    |============| CCC

note that if you violate the "anthropologists > cannibals" rule at any point in time, it is illegal.. for example if a boat with a cannibal and an anthropologist travels to a shore with one cannibal on it, then # cannibals > # anthropologists, even if you say the anthropologist immediately takes the boat back.

solution: easy river crossing

 



home | software development | bug tracking software | archive

[general software discussion] [dogs new york city] [Software Quality]