Question: In this problem, three missionaries and three cannibals must cross a river using a boat which can carry at most two people, under the constraint that, for both banks, that the missionaries present on the bank cannot be outnumbered by cannibals. The boat cannot cross the river by itself with no people on board.
First let us consider that both the missionaries (M) and cannibals(C) are on the same side of the river.
Initially the positions are : 0M , 0C and 3M , 3C (B)
Now let’s send 2 Cannibals to left of bank : 0M , 2C (B) and 3M , 1C
Send one cannibal from left to right : 0M , 1C and 3M , 2C (B)
Now send the 2 remaining Cannibals to left : 0M , 3C (B) and 3M , 0C
Send 1 cannibal to the right : 0M , 2C and 3M , 1C (B)
Now send 2 missionaries to the left : 2M , 2C (B) and 1M . 1C
Send 1 missionary and 1 cannibal to right : 1M , 1C and 2M , 2C (B)
Send 2 missionaries to left : 3M , 1C (B) and 0M , 2C
Send 1 cannibal to right : 3M , 0C and 0M , 3C (B)
Send 2 cannibals to left : 3M , 2C (B) and 0M , 1C
Send 1 cannibal to right : 3M , 1C and 0M , 2C (B)’
Send 2 cannibals to left : 3M , 3C (B) and 0M , 0C
• Here (B) shows the position of the boat after the action is performed.
Therefore all the missionaries and cannibals have crossed the river safely.
This article is contributed by kaushik. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Number of containers that can be filled in the given time
- Find temperature of missing days using given sum and average
- Puzzle | The Counters and Rectangular Board
- Puzzle | Planning an Exhibition
- Puzzle | Place numbers 1 to 9 in a Circle such that sum of every triplet in straight line is 15
- 25 Facts about LTE Technology
- Difference between Neo4j and MongoDB
- Difference between Neo4j and Redis
- Puzzle | Who wins the race on a square field ABCD of 40 acres
- Puzzle | Choose the game of Rolling Dice
- Puzzle | Maximum pieces that can be cut from a Circle using 6 straight lines
- Puzzle | Connect 9 circles each arranged at center of a Matrix using 3 straight lines
- Maximum number of objects that can be created as per given conditions
- Computer Security and its Challenges