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 ?
Solution:
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 contribute@geeksforgeeks.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.
Recommended Posts:
- Program to check if water tank overflows when n solid balls are dipped in the water tank
- Puzzle | Measure 4L using given 3 buckets
- Frequency Measuring Techniques for Competitive Programming
- Puzzle | Measuring Block
- Measuring script execution time in PHP
- Puzzle | Cylindrical Glass and Water Measurement
- Puzzle | Water Jug Problem
- Container with Most Water
- Puzzle | Growing Water Lilly
- Sum and Product of minimum and maximum element of an Array
- Sum and Product of maximum and minimum element in Binary Tree
- Sum and Product of minimum and maximum element of Binary Search Tree
- Sum and product of k smallest and k largest prime numbers in the array
- Sum and product of k smallest and k largest composite numbers in the array
- Difference between Stop and Wait, GoBackN and Selective Repeat
- Difference and similarities between HashSet, LinkedHashSet and TreeSet in Java
- What are the differences and Similarities Between Lumen and Laravel?
- Generate an array of given size with equal count and sum of odd and even numbers
- Maximum Bitwise AND pair (X, Y) from given range such that X and Y can be same
- Building a terminal based online dictionary with Python and bash

