# Puzzle | Three Thief crossing river

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.

1. Thief B crosses first with his bag of 700 coins. He will keep the bag there and will return back.
2. Thief A will now cross the river with the bag which has 300 coins. He will keep the bag and return back.
3. Now thief B and C cross the river and thief C will return back with his bag of 300 coins.
4. Now thief A goes to the other side with his bag of 1000 coins and thief B will return back with his bag of 700 coins.
5. Now thief B and C cross the river together and thief A return back empty handed. Thief A takes the bag of 300 coins and cross the river then thief B is sent to collect his bag of 700 coins.

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 contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

# GATE CS Corner    Company Wise Coding Practice

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.
4.4 Average Difficulty : 4.4/5.0
Based on 9 vote(s)