Worst case in decanting puzzles (pouring water from one jug to others).

544 Views Asked by At

A classic puzzle is to start with $3$ jugs of nonzero integer capacity ($A \ge B \ge C$) and have some water (integer) in each jug (the initial position). The goal is to get to some final (integer) state. Of course, the question makes sense with n jugs, and possibly with a source and/or a sink (which I do not allow in the $3$-jug case). The solution of a particular case is the same as finding a shortest-path in a certain graph.

My question is whether any bounds are known on the number of steps needed. I (and Rob Pratt) have checked the special case where the total amount of water in the initial state is at most A. We checked all choices of the capacities under $100$ and in all cases the longest shortest path (the diameter of the graph) has length (number of edges, which is same as number of pouring steps) at most $A+1$. Without the initial water restriction, the solution length might well be unbounded. I do know that the graph is best studied in barycentric coordinates, and then a pouring sequence corresponds to a billiard path in a certain polygon.

Example for $A+1$: Use jugs $(A,A,2)$ where $A$ is odd. The shortest path from $(A,0,0)$ to $(A-1,1,0)$ takes $A+1$ steps.

I will soon submit a demo to the Wolfram site that shows the graph and the solution for any choice of jugs, start, and finish.

Stan Wagon