Help the Women: There is a mother who wishes to cross a river but she is not alone. She also has 5 daughters of age 6, 7, 8, 9 and 10. There is only one boat available which can support the woman and either two of the daughters. So at a time, the boat can have only three objects (woman and two other). But the problem is that when the mother is absent, daughters with one year difference in age will fight each other. (For example:- When the mother is absent and has taken the daughter of age 6 and 8 with her, then the daughters of age 9 and 10 will fight each other. Similarly, if the mother has taken 6 and 7 with her, then daughters of age 8 and 9 will fight with each other.) The woman wants to cross the river with all her daughters. Only the mother can ride the boat. What strategy she should use to do so?
- Step 1: Firstly,mother will take daughters of age 7 and 9 with her.
- Step 2: She will leave the daughters and return.
- Step 3: Then she will take daughters of age 6 and 8 with her.
- Step 4: She will leave daughters of age 6 and 8 to the other side and take the daughters of age 7 and 9 with her.
- Step 5: Again she will leave daughters of age 7 and 9 and take the daughter of age 10 with her.
- Step 6: She will leave daughter of age 10 to the other side and return alone.
- Step 7: Finally she has taken the daughters of age 7 and 9 with her.
Now, finally, she crosses the river with all daughters.
Cross the River : There is a man who wishes to cross a river but he is not alone. He also has a dog, 2 tigers and 2 elephants along with him. There is only one boat available which can support the man and either one of the animal. So at a time, the boat can have only two objects (man and one other). But the problem is, if the tiger and dog are left alone (either in the boat or onshore), the tiger will eat the dog. Similarly, if the 2 tigers and 1 elephant are left alone, then 2 tigers will eat the elephant. The man wants to cross the river with all the belongings. What strategy should he use to do so?
Step 1:- First the man will take the dog to the other side and return. (One side = Dog, Other side = 2 tigers and 2 elephants)
Step 2:- He will take 1 tiger with him and return with dog.
Step 3:- He will leave the dog and take another tiger with him and move to the other side.
Step 4:- He will take 1 elephant with him and return by taking one tiger with him.
Step 5:- He will take the dog with him and go to the other side. Then he will leave the dog to the other side and
return by taking another tiger with him.
Step 6:- He will leave the tiger and take the elephant with him and return alone.
Step 7:- He will take one tiger with him, leave it there and return with the dog.
Step 8:- He will take another tiger with him and return alone.
Step 9:- Finally, he will taken the dog with him.
This article is contributed by Roshni Agarwal. 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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.