Open In App
Related Articles

Puzzle 54 | Fill the Jug

Improve Article
Improve
Save Article
Save
Like Article
Like

There are two jugs each of 4 and 3 liters respectively , without any measuring marks. how many minimum steps are required to have 2 liters of water into the 4 litre jug (the jugs can be filled any number of times with water, and they can be emptied any number of times). 

  
  

Note that this puzzle is different from the one discussed here. Here we need 2 litre water in 4 litre jug (not in any of the two jugs). 

  
  

Answer: 6
  
Explanation: 

Thinking Recursively:
As we want 2litre water in a 4liter mug, this can be achieved by the following last states:
           1. Having 1litre in a 3litre mug 
           2. Having 2litre in 4litre mug

1. First one as easy to think as the difference between the mugs (4-3 =1) 

Step 1 : Fill 4-litre jug with water completely 
Step 2 : Empty water from 4-litre jug into 3-litre  (leaving 1L in 4litre mug and 3L in 3 litre mug)
Step 3 : Empty water from 3-litre
Step 4 : pour water from 4-litre jug into 3-litre jug (leaving 0L in 4litre mug and 1L in 3 litre mug)
Step 5 : Fill 4-litre jug with water completely again.
Step 6: Transfer water of 4-litre jug to 3-litre jug, resulting in 2 litre water in 4-litre jug. 
       
2. Second approach:
Step 1 : Fill 3-litre jug with water completely 
Step 2 : Empty water from 3-litre jug into 4-litre 
Step 3 : Again, fill 3-litre jug with water completely 
Step 4 : And pour water from 3-litre jug into 4-litre jug until 4-litre jug becomes full 
Step 5 : Empty the 4-litre jug. Now, we are left with 2 litre water in 3-litre jug and 4-litre jug is empty.  
Step 6: Transfer water of 3-litre jug to 4-litre jug, resulting in 2 litre water in 4-litre jug. 

  

This puzzle is contributed by Naziya Parveen. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
 

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 18 Jan, 2023
Like Article
Save Article
Previous
Next
Similar Reads