Question: Suppose you have a 4 liter jug and a 9 liter bucket . The buckets have no measurement lines on them either. How could you measure exactly 6 liter using only those buckets and you have as much extra water as you need ?
Consider 2 buckets one 4L and other 9L. : Bucket 1 (4L) and Bucket2 (9L)
First fill the 9L bucket fully. : 0 L and 9 L
Pour the water into 4L bucket. : 4 L and 5 L
Empty the 4L bucket. : 0 L and 5 L
Repeat this twice. : 4 L and 1 L
Now you will left with 1L water in the 9L bucket : 0 L and 1 L
Now pour this 1L into the 4L bucket : 1 L and 0 L
Refill the 9L bucket. : 1 L and 9 L
Now pour the water from 9L into the 4L bucket until it fills up. : 4 L and 6 L
Now you are left with 6 L water in the 9L bucket.
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.
- Program to check if water tank overflows when n solid balls are dipped in the water tank
- Puzzle | Measure 4L using given 3 buckets
- Puzzle | Measuring Block
- Measuring script execution time in PHP
- Frequency Measuring Techniques for Competitive Programming
- Container with Most Water
- Puzzle | Water Jug Problem
- Puzzle | Growing Water Lilly
- Puzzle | Cylindrical Glass and Water Measurement
- Maximum repeated frequency of characters in a given string
- Count of even and odd set bit with array element after XOR with K
- Minimum number of moves required to solve a Jigsaw Assembly Puzzle
- Find K distinct positive odd integers with sum N
- Radio Button Vs Checkbox in HTML