You have two containers, one which can hold 11 liters of water and the other of which can hold 13 liters. You also have access to a sink with a faucet. You can do any of these three things as many times as you like:
Given these conditions, is it possible to measure out exactly 8 liters?
If this puzzle seems familiar, it might be because a version of this challenge was featured in the third "Die Hard" movie.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Good solution,can be made more clear by editing the steps so that each iteration(getting 4 liters first, then 6 liers, then finally 8 liters in 13-liter bottle) is clear separate step with different numbers of waters getting transferred and remaining. It cannot really be achieved by repeating steps 1-4 the way they are worded currently.
Surely one needs a third container?
After step 2, you forgot to empty the 11-litre bottle. We should understand, but it's a little confusing...
you repeat steps 2-5 not 1-5. please fix even though people will probably understand :)
But where are you keeping the 4 liters that you get in each set of 4 steps. The puzzle does not seem to allow for an additional container in which to put the water from step 4. Step 2 requires an empty 11 liter bottle unless Option 3 opens up the option of a 3rd bottle. Apologies - I didn't read your solution carefully enough.
I agree with the Ray Weston, this solution will require a 3rd bottle. The only way I can see to get 8 L with only 2 buttons is to get the first 4 L in the 13 L bottle as described in this solution, then transfer that 4 L to the 11 L bottle, mark the 4 L level in the 11 L bottlethen empty it. Start the procedure again and when you have 4 L in the 13 L bottle for the 2nd time, fill the emptied 11 litre bottle to the previously marked 4 L level and then tip that back into the 13 L bottle that's already got 4 L in it.
Oops, sorry! I'll do that @Angel ONG
Relevant wiki: Linear Diophantine Equations
Puzzle can be translated to: Does the equation 1 3 x + 1 1 y = 8 have integer solutions?
Answer is "yes". Because according to Bezout's Identity we have g cd ( 1 3 , 1 1 ) ∣ 8 .
How this relates to the puzzle: For measuring 8 liters you have to fill or empty each of containers several times (pouring from one container to another is not considered filling or emptying).
Suppose that you fill 13 liter container a times and empty it b times. So the amount of the water used is 1 3 ( a − b ) liters here. And if you fill 11 liter container a ′ times and empty it b ′ times during the process, then the amount of the water used is 1 1 ( a ′ − b ′ ) liters.
You have measured 8 liters with these actions. Thus, 1 3 ( a − b ) + 1 1 ( a ′ − b ′ ) = 8 . Or even simpler 1 3 x + 1 1 y = 8 , where x and y are some integers.
Notice that for this puzzle we have a = 4 , b = 0 , a ′ = 0 , b ′ = 4 or x = 4 , y = − 4 as the plenty of solutions have showed this.
Could you possibly explain a little more why the equation relates to the problem? (It doesn't need to be lengthy, but I fear some of the audience won't understand the connection.)
Log in to reply
Actually sir Arjen Vreugdenhil did this in his solution.
Sure. I was too lazy to do this :)) Please see if my explanation is good.
Log in to reply
That's fine. And a fair number of users check the first 3 but no farther (at the moment Arjen's isn't in the top 3).
good job thanks again
sorry but i cant understand how this is possible . this is applicable only when you have another container . i.e 4(13) - 4(11) = 8 and 13 - 11 = 2 But there must be another container in which you can store the two litres obtained from the two containers ( 13 and 11 litres) repeating which 8 litres can be obtained. please correct me if i am wrong.
Log in to reply
Look at the process that @Kevin Guo has provided. In that process we fill 13 liter container four times and also empty 11 liter container four times. That's what I predicted using a linear Diophantine equation. Notice that in the process there is no third container.
o thank you
There is a little mistake : you cannot say gcd(11,13) divides 8 for gcd(11,13) = 1, but you can say gcd(88,104) or gcd(44,52) divides 8.
To solve Bezout's identity, you have to solve it in 2 times.
First one : Using the euclidean algorithm : LaTeX: 1 1 x + 1 3 y = 1 Then you notice LaTeX: g c d ( 1 1 , 1 3 ) = 1
LaTeX: 1 3 = 1 1 × 1 + 2 ⇔ − 1 × 1 1 + 1 × 1 3 = 2
LaTeX: 1 1 = 2 × 5 + 1 The remain is 1 , then you stop dividing
Second time, you have to get 8 :
In order to get 8, you need to multiply each member of the equation by 4 :
LaTex: − 4 × 1 1 + 4 × 1 3 = 8
And to conclude, you can say LaTeX: g c d ( 4 4 , 5 2 ) = 4 and g c d ( 4 4 , 5 2 ) divides 8
Log in to reply
g cd ( 1 1 , 1 3 ) ∣ 8 guarantees that the equation 1 1 x + 1 3 y = 8 has integer solutions.
Log in to reply
Great Kazem, I get it : the is the condition required to solve the diophantine equation.
I had recently come across a geometric solution to these types of problems (Source: Mathologer on Youtube ). As can be seen in the figure, we can fix one of the axis above to represent filling the 13 liters container (here, the x-axis), whereas the 60 degrees line can represent filling the 11 liters container. Using simple collision rules, one can work out how to get 8 liters. To translate the figure in steps:
1) Fill the 13 liter container -- shown by the orange line
2) Pour 11 liters in the 11 liters container -- bounce to (2,11)
3) Empty the 11 liters -- bounce to (2,0)
4) Transfer the 2 liters to the 11 liters container -- bounce to (0,2)
5) Fill the 13 liter container -- bounce to (13,2)
6) Pour 9 liters in the 11 liters container -- bounce to (4,11)
7) Empty the 11 liters -- bounce to (4,0)
8) Transfer the 4 liters to the 11 liters container -- bounce to (0,4)
9) Fill the 13 liter container -- bounce to (13,4)
10) Pour 7 liters in the 11 liters container -- bounce to (6,11)
11) Empty the 11 liters -- bounce to (6,0)
12) Transfer the 6 liters to the 11 liters container -- bounce to (0,6)
13) Fill the 13 liter container -- bounce to (13,6)
14) Pour 5 liters in the 11 liters container -- bounce to (8,11) [ Solution already reached ]
15) Empty the 11 liters -- bounce to (8,0) [ Solution already reached ]
16) Transfer the 8 liters to the 11 liters container -- bounce to (0,8) [ Solution already reached ]
@Anant Dixit - very nice, and a very lucid explanation of it as well. Thanks for sharing this. It also provides a geometric interpretation of a solution ( 4 , − 4 ) to the Diophantine equation 1 3 m + 1 1 n = 8 , m , n ∈ Z . If arrowheads are added to each segment representing a step (so it is a directed graph), the 4 east-directed (horizontal) segments represent filling of the 13 L bottle and correspond to m = + 4 while the 4 southwest-directed segments represent emptying of the 11 L bottle and correspond to n = − 4 . And great pic!
Let a > b be the sizes of the bottles.
At every stage of the process, one bottle is either completely full or completely empty. The other bottle contains an amount x . Once we have an amount x < b , it is easily transferred to the other bottle. We determine the amounts x that can be generated.
Clearly, we can easily make the amounts x = 0 , x = a , and x = b by filling or emptying bottles.
There are four operations we may perform.
Thus we can perform x ↦ x ± b and x ↦ x ± ( a − b ) , provided that x remains between 0 and a . Clearly the possible values satisfy x = m a + n b with m , n integers. This implies that x ∣ gcd ( a , b ) is a necessary condition. Is it sufficient? In principle we must perform x ↦ x ± ( a − b ) precisely ∣ m ∣ times, and x ↦ x ± b , ∣ n + m ∣ times. We only must be careful to do them in the correct order, so that x remains between 0 and a .
In this problem, we have a = 1 3 , b = 1 1 , and want x = 8 . Since 8 = 4 ⋅ 2 = 4 ⋅ ( 1 3 − 1 1 ) = 4 ⋅ 1 3 − 4 ⋅ 1 1 , we have m = 4 , n = − 4 . This means that we need the operation x ↦ x + ( a − b ) four times, i.e. transfer x to the small bottle, fill the big bottle, pour big into small--and repeat this four times.
Perfect explanation.
Very good explanation. Does this mean that for any two relatively prime bottle sizes a and b any integer value for x such that x<a can be obtained?
Log in to reply
I left that question unanswered... can you answer it? :)
Mathologer did a video on how to solve this type of question and the solution hi provided in his video How not to Die Hard with Math not only tells us if its possible or not but also tells the exact steps required to attain a given amount of water in a container.
The difference between the two bottles volume is 2. Therefore each time you 1. fill the large bottle 2. pour the larger contents to the smaller 3. pour out the smaller 4. pour the larger contents to the smaller you end up with 2 more liters in the smaller bottle than you started with. Since 8 is divisible by 2, you repeat this 4 times to get 8 liters.
Step 1. Fill 13L container. Step 2. Empty the contents into 11L container. This leaves 2L remaining in the 13L container. Step 3. Empty out the 11L container into the sink. Step 4. Empty the 2L into the 11L container. Step 5. Refill the 13L. Step 6. Fill in 9L into the 11L container, leaving 4L left. Step 7. Do steps 1 - 6 until you have 8L.
It is easier to work it out on paper than drawing out diagrams. But, you can also do this in real life (if you have a 11 and 13L container) and you'd get the same results.
first of all, Fill the 13-liter bottle.
then , pour 11 liters into the 11-liter bottle. This leaves 2 liters of water remaining in the 13-liter bottle.
then, pour the 2 liters of water into the 11-liter bottle.
then, Fill up the 13-liter bottle again and pour 9 liters into the 11-liter bottle. This leaves 4 liters of water in the 13-liter bottle.
if we do this steps we will get 6 liter water and by doing this ,at last we will be able to get 8 liter waters.
1 - Fill the 13 liter container
2 - Pour its contents into the 11 liter container which leaves 2 liters in the other container (13 - 11)
3 - Empty the 11 liter container
4 - Pour the contents of the 13 liter container into the 11 liter container
The 11 liter container now holds 2 liters.
5 - Refill the 13 liter container
6 - Pour its contents into the 11 liter container which leaves 4 liters in the 13 liter container (13 - 11 + 2)
7 - Empty the 11 liter container into the sink
8 - Pour the contents of the 13 liter container into the 11 liter container
9 - Repeat all steps to obtain 6 liters by step 4 and 8 liters in the end.
(STOPPER THE SINK)
(STEP-1) Fill the 13L
(STEP-2) Fill the 11L from the 13L
(STEP-3) Empty 2L remaining from 13L into sink
(STEP-4) Pour 11L into 13L
(DO STEPS) 1,2,3,4) four times gathering 2L, 4L, 6L, 8L in the sink.
Fill the 13 Liters- 11 Liters (pour it into the 11 Liters) =2 Liters in the 13 Liter bottle pour this into the sink then repeat the first step 4 times (fill up the 13 Liter container, empty it into the 11. Pour it into the sink...)
1.Fill the 13-liter bottle.
2.Pour 11 liters into the 11-liter bottle. This leaves 2 liters of water remaining in the 13-liter bottle.
3.Empty the 11 liter bottle.
4.Pour the 2 liters of water into the 11-liter bottle.
5.Fill up the 13-liter bottle again and pour 9 liters into the 11-liter bottle. This leaves 4 liters of water in the 13-liter bottle.
Repeat this and you'll eventually you'll get 8L
13 and 11 are coprime, so there MUST be a solution. A solution can be found for any multiple of GCF of (a,b) units, where a,b are integers.
Applying modulo operation.
Filling the 13 liter bottle by the 11 bottle results in a non-integer.
x*(11mod13)=8
11x=8
x=8/11
Filling the 11 bottle by the 13 bottle gives the right answer
x*(13mod11) = 8
2x=8
x =4
One need 4 steps of collecting the remainder of 2 liter in the way, described in the other answers, to obtain 8 liter.
If you have the 11 liter bottle filled and the 13 liter bottle has x liters water, then if you pour water from the 11 liter bottle to the 13 liter bottle so that it gets full, x − 2 liters will remain in the 11 liter bottle.
We can fill the 13 liter bottle and repeatedly fill the 11 liter bottle, pour some of it to the 13 liter bottle, empty the 13 liter bottle and finally pour the water in 11 liter bottle to the 13 liter bottle until there's only 1 liter left in the 13 liter bottle. We know this can be done because one action lowers the amount of water in the 13 liter bottle by two and 1 3 − 2 − 2 − 2 − ⋯ − 2 = 1 . Now when we pour 11 liters to the 13 liter bottle, it will have 12 liters inside. No we need to repeat the same action as before twice to get to 8 liters (because 1 2 − 2 − 2 = 8 ).
At this Point you can stop the process, because it is just adding rests. 11 and 13 are coprime numbers and it's possible to Keep the rest of both in one of this bottles. The residue classes of a multiple of two coprime numbers are leaving every possible rest before they reach a multiple of 13 (in this case it is of course not possible to reach an odd liter which is not 11 or 13, because it's just possible to subtract them and the difference is even)
13-11=2 2*4=8 litres. This is why there can be an exact 8 litres.
If m>n, and m & n are mutually prime, any amount between m-n to m+n is possible. I wrote a c++ program years ago that writes out every step.
Size of 1st container: 11
Size of 2nd container: 13
Input target number = 8
(1) Start by filling the 13 container first. (2) Start by filling the 11 container first. (3) Silenty run both methods, and print only the most efficient. (TAKES LONGER) (4) Exit Program. Select an above method: 3
Filling the 13 first was more efficient by 17 steps.
(1)Fill the 13-gal 13/13 0/11 (2)Pour the 13-gal into the 11-gal (until full) 2/13 11/11 (3)Empty the 11-gal 2/13 0/11 (4)Transfer the 2-gals into the 11-gal container. 0/13 2/11 (5)Fill the 13-gal 13/13 2/11 (6)Pour the 13-gal into the 11-gal (until full) 4/13 11/11 (7)Empty the 11-gal 4/13 0/11 (8)Transfer the 4-gals into the 11-gal container. 0/13 4/11 (9)Fill the 13-gal 13/13 4/11 (10)Pour the 13-gal into the 11-gal (until full) 6/13 11/11 (11)Empty the 11-gal 6/13 0/11 (12)Transfer the 6-gals into the 11-gal container. 0/13 6/11 (13)Fill the 13-gal 13/13 6/11 (14)Pour the 13-gal into the 11-gal (until full) 8/13 11/11 (15)Empty the 11-gal 8/13 0/11 Press any key to continue . . .
Solution: realise it would be a stupid question if the answer was no and if would have been in die hard if it wasn't possible
Problem Loading...
Note Loading...
Set Loading...