The Water Jug Riddle
Detective John McClane must measure out exactly 4 gallons of water and place the resulting weight on a scale to disable a bomb. His tools are yours: a 3-gallon and a 5-gallon jug—and a single fountain. McClane did it in less than 5 minutes. Can you also do it in time and provide a generalized solution for arbitrary gallons of both jugs?
Jug 1
Jug 2
5
3
Every step can be visualized as billiard moves in the coordinate system on a triangular lattice. The above hexagonal plot gives two solutions to the 5-gallon and 3-gallon puzzle. Each point on the boundary denotes combinations achievable with the jugs. Starting at two vertices (5, 0) and (0, 3), traces of the blue points show pourable transitions. We have measured 4 gallons in 6 and 7 steps concerning the starting points. Might it be possible to get a prime gallon of water from coprime gallon jugs (e.g., to yield 7 gallons from a 9-gallon jug and 15-gallon jug)?