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 email@example.com. 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.
- Puzzle | Measure 4L using given 3 buckets
- Program to check if water tank overflows when n solid balls are dipped in the water tank
- 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
- Maximize the happiness of the groups on the Trip
- Queries to find the last non-repeating character in the sub-string of a given string
- Monads in Scala
- Method Overriding in Scala
- Scala | aggregate() Function
- Scala | Variances