You have two jugs. One of the jugs is a three-gallon jug, and the other is a five-gallon jug. We need exactly four gallons of water. You are allowed to use only the water, and the jugs provided to accomplish your task.

How do you do it?

SOLUTION:

We start with two empty jugs.
[ 0/3 GAL ] - [ 0/5 GAL ]

Fill the five-gallon jug.
[ 0/3 GAL ] - [ 5/5 GAL ]

• Fill the three-gallon jug from the five-gallon jug.
[ 3/3 GAL ] - [ 2/5 GAL ]

Empty the three-gallon jug.
[ 0/3 GAL ] - [ 2/5 GAL ]

Transfer the two gallons from the five-gallon jug to the three-gallon jug.
[ 2/3 GAL ] - [ 0/5 GAL ]

Refill the five-gallon jug.
[ 2/3 GAL ] - [ 5/5 GAL ]

• Fill the remainder of the three-gallon jug.
[ 3/3 GAL ] - [ 4/5 GAL ]

The five-gallon jug now contains exactly four gallons of water. Feel free to pour out the three-gallon jug.