Last weekend, I saw an old friend of mine (in fact, he was the composer of an opera I performed in several decades ago!) who recently subscribed to The Fiddler. He confessed that the last time he encountered math puzzles like these, they were water pouring puzzles. “Oh, I can do one of those!,” I exclaimed.
So Joel, this week’s puzzle is dedicated to you!
I have two large pitchers with known volumes: 10 liters (“pitcher A”) and 3 liters (“pitcher B”). They are both initially empty. I can do one of six things with the pitchers:
I can fill pitcher A to the top with water from the sink.
I can fill pitcher B to the top with water from the sink.
I can empty the contents of pitcher A into the sink.
I can empty the contents of pitcher B into the sink.
I can transfer the contents of pitcher A to pitcher B, until pitcher A is empty or pitcher B is filled to the top—whichever comes first.
I can transfer the contents of pitcher B to pitcher A, until pitcher B is empty or pitcher A is filled to the top—whichever comes first.
Every time I do any one of the above six, it counts as a step.
What is the fewest number of steps required until one of the pitchers (either A or B) contains precisely 5 liters of water?
Step | Pitcher Action | Volume of A | Volume of B |
---|---|---|---|
1 | Fill B. | 0 | 3 |
2 | Empty B into A. | 3 | 0 |
3 | Fill B. | 3 | 3 |
4 | Empty B into A. | 6 | 0 |
5 | Fill B. | 6 | 3 |
6 | Empty B into A. | 9 | 0 |
7 | Fill B. | 9 | 3 |
8 | Fill A with 1 liter from B. | 10 | 2 |
9 | Empty A. | 0 | 2 |
10 | Empty B into A. | 2 | 0 |
11 | Fill B. | 2 | 3 |
12 | Empty B into A. | 5 | 0 |
To be sure, I checked starting with A.
Step | Pitcher Action | Volume of A | Volume of B |
---|---|---|---|
1 | Fill A. | 10 | 0 |
2 | Fill B from A. | 7 | 3 |
3 | Empty B. | 7 | 3 |
4 | Fill B from A. | 4 | 3 |
5 | Empty B. | 4 | 0 |
6 | Fill B from A. | 1 | 3 |
7 | Empty B. | 1 | 0 |
8 | Fill B with 1 liter from A. | 0 | 1 |
9 | Fill A. | 10 | 1 |
10 | Fill B with 2 liters from A. | 8 | 3 |
11 | Empty B. | 8 | 0 |
12 | Fill B from A. | 5 | 3 |
Achieving 5 liters takes a minimum of 12 steps. This can be done in two ways.
Instead of 10 liters and 3 liters, suppose the volumes of the pitchers A and B are now 100 liters and 93 liters, respectively.
Further suppose that the fewest number of steps needed until one of the pitchers (either A or B) contains precisely N liters of water is f(N), where N is a whole number between 1 and 100, inclusive.
What is the maximum value of f(N), and for which value of N does this occur?
I created code that did the following :
I used a breadth first search as it guarantees that the array is populated by the minimum number of steps or not at all.
Achieving 50 liters takes 190 steps.
I plotted my results of all pitcher sizes from 1 to 200 liters.
If the $gcd(a,b) ≠ 1$, they were removed, as not all pitcher sizes would be possible for that pair.
The volume that requires the maximum number of steps is exactly half of the larger of the two pitchers if the larger is even. This is observable at the blocks of the same color in any even row or column.
I could not determine any immediate pattern if the larger pitcher is odd.
The steps required to achieve that volume is also plotted.
This seems to be directly proportional to the size of the pitchers, so I graphed a ratio, $r = \dfrac{\text{Number of Steps}}{\text{Volume of A and B}}$ .