Three Jugs Puzzle

Divide the wine equally into two.

Click a tap to turn the handle.
Click a jug to attach the taps.

1. Pouring stops automatically if one of the jugs becomes full.


1. Abbot Albert wrote a version of this puzzle ~1240. [5]
2. Niccolò Fontana Tartaglia wrote a version of this puzzle in the 1500s. [4]
3. In the film Die Hard With a Vengeance (1995), New York City Police Lieutenant John McClane (Bruce Willis) and shopkeeper Zeus Carver (Samuel L. Jackson) team up and solve a version of this puzzle to stop a bomb from exploding.
4. Professor Stewart's Hoard of Mathematical Treasures (2010), by Ian Stewart.
5. Rediscovering Mathematics: You Do the Math (2011), by Shai Simonson.

Text Version
You have an 8 liter jug full of water, and two empty jugs which respectively hold 3 and 5 liters. Measure precisely 4 liters of water by pouring between the jugs.