Brainteasers · Strategy and invariants · Medium
A seven and a four
You have a 7-litre jug and a 4-litre jug, both empty and unmarked, a tap and a drain. A move is one of three things: fill a jug to the brim from the tap, empty a jug completely down the drain, or pour from one jug into the other until the first is empty or the second is full. What is the smallest number of moves after which the 7-litre jug holds exactly 5 litres?
Answer and solution
Answer
8
Solution
Fill the small jug and pour into the large one repeatedly: the large jug's contents step through the multiples of 4 reduced by 7.
Fill the 4; pour into the 7 (7 holds 4); fill the 4; pour until the 7 is full (1 litre stays in the 4); empty the 7; pour the 1 litre into the 7; fill the 4; pour into the 7, which now holds 5. That is 8 moves. Going the other way, filling the 7 and pouring into the 4, first puts 5 litres in the large jug after 12 moves. The answer is 8.
Strategy and invariants comes up in 3 firms' roundsMillennium · Point72 / Cubist · IMC
These 3 rounds ask this kind of problem live, with follow-ups. Every round on every track is in Premium.