VLSI DV Interview Puzzles · All levels
Measure 4 Liters with 3L and 5L Jugs
You have unmarked 3-liter and 5-liter jugs plus unlimited water. Measure exactly 4 liters.
Puzzle
Difficulty: Easy · Puzzle 4 of 6 · Topic: Classic Brain Teasers
You have unmarked 3-liter and 5-liter jugs plus unlimited water. Measure exactly 4 liters.
Hint
Create a 2-liter remainder first, then use it as an offset.
Step-by-step solution
diagram
1) Fill 5L jug and pour into 3L jug => 5L now has 2L left.
2) Empty 3L jug.
3) Pour the 2L from 5L into 3L jug.
4) Fill 5L jug again.
5) Pour from 5L into 3L until 3L is full; it needs 1L to go from 2L to 3L.
6) So 5L jug is left with exactly 4L.Answer
Answer: Sequence leaves 4 liters in the 5L jug after creating 2L in the 3L jug and topping it up.
Why candidates get it wrong
Trying to directly make 4L in one move instead of using intermediate remainders.
Interviewer follow-up
Can you derive a general solvability rule for jug sizes a and b?