Initially each jug contains a known integer volume of liquid, not necessarily equal to its capacity.
It is a common assumption, stated as part of these puzzles, that the jugs in the puzzle are irregularly shaped and unmarked, so that it is impossible to accurately measure any quantity of water that does not completely fill a jug.
The puzzle may be solved in seven steps, passing through the following sequence of states (denoted as a bracketed triple of the three volumes of water in the three jugs): Cowley (1926) writes that this particular puzzle "dates back to mediaeval times" and notes its occurrence in Bachet's 17th-century mathematics textbook.
This version of the puzzle was featured in a scene of the 1995 movie Die Hard with a Vengeance.
[4] This variant has an optimal solution that can be obtained using a billiard-shape barycentric plot (or a mathematical billiard).
[5] The graph shows two ways to obtain 4 liters using 3-liter and 5-liter jugs, and a water source and sink on a Cartesian grid with diagonal lines of slope −1 (such that
If and only if the jugs' volumes are co-prime, every boundary point is visited, giving an algorithm to measure any integer amount up to the sum of the volumes.As shown in the previous section, we can construct the solution to the problem from the desired result by using reversible actions only (emptying a full jug into the sink and filling an empty jug from the tap are both reversible).
These solutions can be visualized by red and blue arrows in a Cartesian grid with diagonal lines (of slope -1 such that
[7] In consequence the steps can be visualized as billiard moves in the (clipped) coordinate system on a triangular lattice.
Starting at the square, solid red and dashed blue paths show pourable transitions.