The Puzzle: You have a 3-litre jug, a 5-litre jug, and an unlimited supply of water. How can you measure exactly 4 litres of water?
1. The Methodical Approach
There are usually two ways to solve these: starting with the small jug or starting with the large jug.
Solution A: Start with 5L Jug
- Fill the 5L jug. (5L in 5-jug, 0L in 3-jug)
- Pour 5L into 3L jug. (2L in 5-jug, 3L in 3-jug)
- Empty 3L jug. (2L in 5-jug, 0L in 3-jug)
- Pour the 2L from 5L into 3L jug. (0L in 5-jug, 2L in 3-jug)
- Fill the 5L jug again. (5L in 5-jug, 2L in 3-jug)
- Pour from 5L into 3L jug until full. (The 3L jug only has 1L of space left).
- Result: You have 4 Litres remaining in the 5L jug!
Interview-Focused Questions
Q: Can you measure ANY amount using two jugs of size A and B?
A: No. You can only measure amounts that are multiples of the Greatest Common Divisor (GCD) of A and B. For example, with a 6L and 3L jug, you can only measure 3 and 6, never 4.
Q: Is there a faster way?
A: You can also start by filling the 3L jug first. In many cases, one path is shorter than the other. In a Die Hard movie version of this puzzle, efficiency was a matter of life and death!
Summary Formula
The state of the jugs can be represented as (x,y). You are basically solving the equation 5x+3y=4 for integers x and y.
Premium Content
Unlock 3 Jugs Puzzle and all premium lessons with a subscription.
From ₹199.99/year — See plans