Log Date

Welcome to techInterview, a site for technical interview questions, brain teasers, puzzles, quizzles (whatever the heck those are) and other things that make you think!

1. Text post

### Easy River Crossing

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 - anthropologistC - cannibal++ - boat         riverAAA |============|    |++          |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

Let W be the west shore which they are all on. Let E be the east shore where they want to go.

`1. A and C crossW = { A, A, C, C }E = { A, C } 2. A returnsW = { A, A, A, C, C }E = { C } 3. C and C crossW = { A, A, A }E = { C, C, C } 4. C returnsW = { A, A, A, C }E = { C, C } 5. A and A crossW = { A, C }E = { A, A, C, C } 6. A and C returnW = { A, A, C, C }E = { A, C } 7. A and A crossW = { C, C }E = { A, A, A, C } 8. C returnsW = { C, C, C }E = { A, A, A } 9. C and C crossW = { C }E = { A, A, A, C, C } 10. C returnsW = { C, C }E = { A, A, A, C } 11. C and C crossW = trueE = { A, A, A, C, C, C }`