# The Die Hard Water Jug Riddle (Solved)

This riddle is from famous Die Hard movie where *Bruce Willis* and *Jackson* have to diffuse a bomb by placing exactly 4 gallon water on a scale using 3 gallon and 5 gallon water jug.

## Riddle

You have a 3-gallon and a 5-gallon jug that you can fill multiple times from a tap 🚰. The problem is to measure exactly 4 gallons of water.

**How do you do it?**

Think for a while before looking at the solution.

## Solution

Firstly you will try to measure 4 gallons of water by estimation. For e.g. adding 3 gallons of water to 1/3 of the 3 gallon jug. But this riddle is asking for a precise measurement so this won’t work.

We can quick realize this:-

5 – 3 = 2 and 5 – (3 – 2) = 4

Here is one of the solution of this riddle:

Action | 3-gallon jug | 5-gallon jug |
---|---|---|

Fill up 5-gallon jug | - | 5 |

Fill up 3-gallon jug with water from 5-gallon jug | 3 | 2 |

Pour out 3-gallon jug | 0 | 2 |

Transfer water from 5-gallon jug to 3-gallon jug | 2 | 0 |

Fill up 5 gallon jug again | 2 | 5 |

Transfer water from 5-gallon jug to 3-gallon jug | 3 | 4 |

That’s not the only solution. There are multiple solutions possible for this riddle.

Incidentally, the reason we can find a solution is because the two numbers 5 and 3 are prime numbers (i.e. they have no common divisors). We can actually generate any volume of water from 1 to sum of these two prime numbers (i.e. 5 + 3 = 8) (in fact, we did get measurements of 2, 3, 4, 5 and 7 along the way in our solutions).

- We have measured 2 and 3 in 3-gallon jug along the way in our solution
- We have measured 4 and 5 in 5-gallon jug along the way in our solution
- We have measured 7 in last two actions summing up gallons in both jugs
- we can measure exactly 8-gallons by filling up both 5-gallon and 3-gallon jugs