Learn / Library / Brainteasers
Restricted pouring rules
A cook has a -litre pot and a -litre pot, both empty, and a tap. Only operations are allowed: fill the -litre pot from the tap, pour the -litre pot into the -litre pot until the small pot is empty or the large pot is full, and empty the -litre pot into the sink. What is the minimum number of operations after which the -litre pot holds exactly litres?
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
Only the small pot can be filled and only the large pot can be emptied, so follow the pair (small, large) step by step.
Solution
- rounds of fill and pour fill the large pot and leave litre in the small pot after operations, so the pair is (, ).
- Empty the large pot and pour in the litre ( more operations), then fill and pour another times ( operations): the pair is (, ) after operations in total.
- Empty the large pot, pour in the litres, fill the small pot and pour it in: the large pot holds litres.
- A search over the pairs confirms that no shorter sequence of these operations gives litres.
- Counting all operations on this route gives .
Answer: