You are here

Two jugs riddle - Systematic Problem Solving

Water Jug Riddle from Die Hard 3: Test Your Problem Solving Skill

Use Common Sense Reasoning to Solve the Water Jug Riddle from Die Hard 3

Measure 4 liter of water with two empty jugs of 5 liter and 3 liter capacity and a tank full of water. Fill and pour as many times as you want.

How many ways can you measure 4 liters of water by repeating fill and pour moves?

Recommended time to solve the riddle: 15 minutes.

Hint: Think where to start.


Learn how to solve this famous water jug riddle from Die Hard 3 with no random trial and error action, using only common sense reasoning.

Water Jug Riddle from Die Hard 3: Step by Step Solution Based on Common Sense Reasoning

You don't have the jugs with you. Imagine what happens if you fill a jug and pour the water into the other jug.

Stage 1: Visualizing Results of Moves

It'll be easy to decide the result of a move in this way—all in your mind. Take an example of two fill and pour actions.

  1. Fill the 3-liter jug from the tank.
  2. Empty the 3-liter jug into the 5-liter jug.

The RESULT of these two actions,

  • The 3-liter jug empty and
  • 3 liter of water in the 5-liter jug.

Did we consider all outcomes? No, we missed the 2 liters of empty volume in the 5-liter jug. This empty volume is crucial because it determines how much water can be poured in the next steps.

It is important to know the result of an action thoroughly at every step of your thinking, leaving out no detail.

Thoroughness is an important aspect of efficient thinking.

With precision, all results of first two trial moves:

  • 3 liter of empty volume in the 3-liter jug.
  • 3 liter of water in the 5-liter jug.
  • 2 liter of empty volume in the 5-liter jug.

Key takeaway:

  1. Abstract visualization: Mental visualization of a fill and a pour action and the result.
  2. Precise thinking: Ensuring no result of a fill and a pour action left out.

Representing details of each fill or pour action in text is cumbersome and lacks precision. We'll use a more convenient and precise way of representation.

Stage 2: Use Arithmetic Equations to Represent Fill and Pour Actions and the Results

Translate the results of fill and pour actions into simple arithmetic equations of numbers that are the volumes.

Example: If you fill the 3-liter jug from the fully filled 5-liter jug, the results in terms of volumes:

  • 5-liter jug: 5 - 3 = 2 (2 liter of water and 3 liter empty)
  • 3-liter jug: 0 + 3 = 3 (fully filled to 3 liter)

Instead of a sentence describing actions and results, the same is first broken up into smaller steps and represented clearly in this form of equivalent arithmetic equations. In addition, these equations help to track and analyze the actions and results immensely.

Key takeaway:

  • Abstract representation: Using abstraction of arithmetic equations representing a fill and a pour action makes representation and analysis easier.

Stage 3: Decide the Right Starting Point of the Series of Fill and Pour Actions Needed to Solve the Riddle

How would you start? Would you try randomly filling a jug and pouring? Realize this approach is random and uncertain.

Necessity in efficient problem solving: At every step of an efficient solution, one must avoid taking a random decision.

The only result in the series of actions for solution known with complete certainty is the final objective—5-liter jug with 4 liter of water. Start by identifying how this result could be achieved by fill and pour actions. Not only would it be easy to identify the actions needed, this starting would also ensure no random action.

A simple way to achieve the target result:

  • Pour 3 liter of water from the 3-liter jug into the 5-liter jug containing 1 liter of water.

By starting from the ultimate end target, we can work backward to identify the exact steps needed, eliminating unnecessary actions and saving time to solve.

This is the End State Analysis technique that often ensures the most efficient solution in the least amount of time.


Time to modify the target to achieve: from the final result to this intermediate result.

Stage 4: Work backward to discover how to get 1 liter of water in the 5-liter jug: Intermediate target

Use arithmetic equations of volumes to get 1 liter water in 5-liter jug:

(3 + 3) - 5 = 1.

This equation means, filling the 3-liter jug twice gives 6 liter, and pouring 5 liter from it leaves exactly 1 liter.

It is equivalent to two practical volume equations,

  • 3 + 3 = 6, and
  • 6 - 5 = 1.

Stage 5: Solution to Reach Intermediate Target: Getting 1 liter water in the 5-liter jug

Convert the two volume equations to practical fill and pour actions.

For example, the equation 3 + 3 = 6 translates to filling the 3-liter jug twice, while 6 - 5 = 1 translates to pouring water from the 3-liter jug into the 5-liter jug until it is full.

So, translate 3 + 3 = 6 to,

  1. Fill the 3-liter jug.
  2. Empty the 3-liter jug into the 5-liter jug.
  3. Fill the 3-liter jug again (both jugs have 3 liter of water).

And translate 6 - 5 = 1 to,

  1. Pour water from the 3-liter jug to fill the 5-liter jug (having 3 liter of water). You will need exactly 2 liter of water to fill the 5-liter jug, leaving 1 liter in the 3-liter jug. Now you need to transfer this 1 liter into the 5-liter jug.
  2. Empty the 5-liter jug into the tank.
  3. Pour 1 liter from the 3-liter jug into the empty 5-liter jug. Intermediate target reached.

Stage 6: Ultimate Solution

Actions for ultimate solution: Fill the empty 3-liter jug again and pour 3 liter of water to the 5-liter jug:

Result: With 1 liter already in the 5-liter jug, this addition of 3 liter makes 4 liter of water in the 5-liter jug. Ultimate target reached.

Representative fill and pour steps:

  1. Fill the empty 3-liter jug.
  2. Empty it into the 5-liter jug. Result: 4 liter of water in the 5-liter jug.

Solution reached in 8 moves.

Steps of actions and results shown in table below.

First solution to two water jug riddle from Die hard 3

Key Techniques Used:

  1. Abstraction of fill and pour actions into equations of water volumes broke down complexity into precise, manageable steps. This improved clarity and made manipulating the actions easier.
  2. Awareness of empty volumes after fill actions.
  3. Deciding the starting point with no uncertainty as the ultimate target and working backward to identify the intermediate target. Use of the End state analysis and Working backwards problem solving techniques.
  4. Abstraction in reverse to translate back volume equations into fill and pour actions.

Part 2: All Solutions to the modified Water Jug Riddle from Die Hard 3

The key idea in the first solution was to represent the ultimate target achieving action as, 1 + 3 = 4. Extend this idea to get 4 as the result of equations.

Identify all volume equations to get the result of 4 liter of water in the 5-liter jug: The first number in the LHS will represent the volume of water in the 5-liter jug.

  • 1 + 3 = 4 (first solution)
  • 5 - 1 = 4 (1 liter poured out from the filled 5-liter jug)
  • 3 + 1 = 4 (Not feasible because: after you get 1 liter of water in the 3-liter jug, you need one more 3-liter jug to form 3 liter water that you would pour into the 5-liter jug. You don't have the extra jug.)
  • 2 + 2 = 4 (Not feasible for the same reason).

Only other solution: 5 - 1 = 4.

This solution works because pouring out 1 liter from a full 5-liter jug leaves exactly 4 liter in it, which is our target.


Second Solution: Ultimate Target 5 - 1 = 4: Find Intermediate Target First

To pour 1 liter from the fully filled 5-liter jug, intermediate target:

  • 2 liter of water in the 3-liter jug (with 1 liter empty volume). Next you would fill the 3-liter jug from filled up the 5-liter jug, leaving 4 liter of water in the 5-liter jug.

The fill and pour actions to reach the intermediate target first and then reach the ultimate target: The Second Solution:

  1. Fill the 5-liter jug.
  2. Fill the 3-liter jug from the 5-liter jug. 2 liter of water remains in the 5-liter jug.
  3. Empty the 3-liter jug into the tank.
  4. Pour 2 liter of water from the 5-liter jug into the empty 3-liter jug. The 3-liter jug has 2 liter of water and 1 liter of empty volume.
  5. Fill the 5-liter jug.
  6. Fill the 3-liter jug, pouring 1 liter from the filled up 5-liter jug. 4 liter of water remains in the 5-liter jug.

Steps of actions and results shown in table below.

Second solution to two water jug riddle from Die Hard 3

Solutions to the puzzle are only two. The second solution reached in two steps less than the first. In terms of fill and pour actions, this is the more efficient and hence the better solution.

Additional advantage: Conclusions mathematically proved.


The Critical Role of Translating Fill and Pour Actions to Arithmetic Equations

Imagine how challenging it would have been to confidently determine that the two jug riddle has only these two solutions without translating the fill and pour actions into simple arithmetic equations!

This strategy belongs to a broader problem solving technique known as domain modeling.

When you transform the essentials of a problem from one area (or domain) into an accurate representation in another area, and achieve breakthrough results using the tools and properties of the second domain, you are applying the domain modeling technique.

In solving the two jug riddle, you translated the essentials of fill and pour actions from their original domain into the domain of arithmetic equations. This allowed you to use the power of simple mathematics to not only discover the second solution but also confirm that only two solutions to the riddle exist.


Sum up

Target directed systematic problem solving techniques comprising the End state analysis technique, the Abstraction technique and the Working backwards technique offer assurance and efficiency.

All solutions could be discovered without any random actions using domain modeling problem solving technique.


If You are More Interested

This is an example of the class of two water jug puzzles that has many variations and different approaches to solutions:

  • 2 jugs of water problem solution: geeksforgeeks.org : "There are several variations of Water and Jug Problem. The problem discussed here can be modeled by means of the Diophantine equation of the form mx + ny = d which is solvable if and only if gcd(m, n) divides d. Also, the solution x,y for which equation is satisfied can be given using the Extended Euclid algorithm for GCD": The approaches discussed here are mathematical, often using higher maths.
  • Water Jug Problem in Python: javatpoint.com: Python being the most favored computer language worldwide including in schools, it is not surprising to get a well-explained solution of the water jug problem in Python code.
  • Water jug problem solution: stackoverflow.com: Varieties of solution are mentioned with resource links including "An amazing and amusing approach (for 3 jugs) is through barycentric coordinates (really!), as described at the always brilliant website Cut-the-Knot: Barycentric coordinates: A Curious Application." The naïve approach to the water jug problem solution explained also is mathematical.
  • Water Jug Problem in AI: geeksforgeeks.org : This era suddenly being transformed from information tech driven to AI driven, it is good to know the role of AI in solving this classic puzzle.
  • Go through a few solutions from the search results with the search phrase "water jug riddle from die hard 3". You will gain new insights.

To explain concepts in higher maths and math based methods, even in advanced management, the core model of such puzzles are sometimes used for attracting the attention of students.


More puzzles to enjoy

From our large collection of interesting puzzles enjoy: Maze puzzles, RiddlesInventive puzzles, ParadoxesMathematical puzzles, Logic puzzles, Number lock puzzles, Missing number puzzles, River crossing puzzles, Ball weighing puzzles and Matchstick puzzles.

You may also look at the full collection of puzzles at one place in the Challenging brain teasers with solutions: Long list.

Enjoy puzzle solving while learning problem solving techniques.