Puzzle | David and Goliath
David and Goliath live on an island Geeksland. One day they both start fighting over an algorithm and realize both of them cannot live together. They want to kill each other. Geeksland has seven poisoned wells, numbered from 1 to 7. If you drink from a well, you can only save yourself by drinking from a higher numbered well.
If you drink water from well number 3 and follow it up by drinking water from any one of wells 4,5,6 or 7, it acts as anti-venom and you are saved.
Well 7 is located at the top of Geeks mountain. Only Goliath is able to reach well number 7. This means David can access wells 1-6 and Goliath has access to wells 1-7.
They decide that to resolve this issue each of them will bring a glass of water. They will exchange their glasses and drink the water. After the duel, David lives and Goliath dies.
What strategy did David use to survive?
HINT: Think not only outside the box but outside the island.
Solution: Goliath knew that David cannot reach well number 7. So he would get water from well 6 or 7 for David. As a result, he thinks David would die.
David knew that no matter from which well he gives the water, Goliath will go and drink water from well 7 and live.
The problem statement clearly mentions that both of them live on an island.
So, David got sea water for Goliath and before duel drank water from well number 1. When they exchanged glasses and drank water, Goliath rushed to well 7 and drank poison from it, thinking that it would cure the poison he just drank (but he drank sea water), so Goliath died.
David on the other hand already had poison from well 1 so what Goliath gave him effectively cured him. So he lived.
This article is contributed by Ankit Jain. 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.