Three Thief need to cross a river. Each thief has certain amount of stolen gold coins kept in his bag.
Thief A has 1000 gold coins
Thief B has 700 gold coins
thief C has 300 gold coins
To cross the river there is a boat which can carry a maximum of two objects at a time that means either a maximum of two thieves can cross the river or a thief with a bag can cross the river. The problem is that in this process of crossing the river if a thief is left with an amount of coins more than his own then he will run away with that. The same rule applies for two thieves, if they are left with a total of more than their cumulative gold coins then they will run away with that money.
What strategy will ensure that they all cross the river properly ?
Solution: They all will cross the river in following manner.
So, finally they all cross the river properly.
This article is contributed by R_Raj. 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.