I am a mathematician and I like action movies Particularly Die Hard is one of my favourites You know action movies and there is one which has a couple of maths problems and one very famous one is In this clip, so just play the clip and then we talk about a little bit Careful don’t open it.
What I gotta open and it’s gonna be alright I told you not to open it! I trust you see the message It has a proximity circuit. So please don’t try Yeah, I got it. We’re not gonna run. How we turn this thing off? On the fountain there should be two jugs, do you see them, a 5 gallon and a 3 gallon? Fill one of the jugs with exactly four gallons of water and place it onto the scale and the timer will stop Must be precise one answer more or less will result in detonation if you’re still alive wait, wait a sec I don’t get it you get it
(5, 1) you can go there So this connection here stands for something that really works in reality, okay? That is the second kind of connection here, and that’s this one here It’s exactly the same sort of thing instead of filling an empty five Or empty a full five you’re now filling an empty three or emptying a full three okay? So exactly the same thing this sort of connection here corresponds to something that really works in reality, okay? I’ve got a third kind of connection. It goes this way Well as if this actually will become more complicated here the situation because well, you can have a connection like that You can also have something like this And it can be done there and there. So you know, what what’s going on here? Well for this one here to really see what’s what’s going on. It’s actually helpful to kind of go in little segments here so let’s start from here and just Go to this point here Okay, that’s actually three one, okay So it’s three over one over. So what what are we actually doing when we’re kind of moving along this this segment? well, we are kind of Pouring water out from the from the big one from the five gallon one and we’re filling it into the other one, right? So here we start with (4, 0). We’re going one down and one up total amount of water stays the same right and So we’re moving in this direction. We’re basically pouring water from here to there One segment here corresponds to one gallon that is busy making a transfer, and you hit the other side Well, you got exactly the right amount you can basically hitting this boundary so it’s going to work all right so it’s going to work This sort of transfer again Corresponds to something that you know happens in reality So these these two points when you actually connect them You know that that really works. Now the path of the billiards ball it’s just made up from these individual segments that work, right? so if we start out with something that we can actually achieve like a (5, 0) Then all the other bits are connected by a things that works or the whole thing has to work So we automatically do the right thing nothing can go wrong okay, what else? Well, at some point in time there’s going to be Die Hard 25 and Actually actually pride myself that I’m a little bit I looked quite similar to Bruce Willis So I’m going to see whether I can be Bruce Willis in Die hard 25, and then solve the problem with my method here so, but in Die Hard 25, there’s also going to be a Simon’s going to be back as out of prison by now. I don’t know actually if maybe he died, he probably died… You can check it? Okay Giuseppe is going to check it. He’s gonna check it on his iphone while I keep talking Anyway, so let’s say Simon’s back either from prison or from the dead, and he’s going to tell me well this time I’m going to make it harder for you I’m going to have a 6 gallon jug and a 15 gallon jug and what I want you to make is a 5 gallons of water Okay and I’m going to you know see whether my method actually works, right? So what I’m going to do is I’m going to make Up a billiards table that has the dimensions 15 and 6 and then I’m going to just run my ball again And I know well Fingers crossed and see what happens when I run my ball and actually I mean there’s a bit of a problem here because the Biltz ball actually doesn’t hit every single one of the points down here, so it doesn’t hit any one of the Doesn’t hit the one, doesn’t hit the two, it hits the three, not the four and not the five, hits the six and in fact All the coordinates that you come across here are multiples of three and That’s sort of true in General, so if you’ve got you know volumes here and there then What you can do is… what you have to do – is you basically take the greatest common divisor of the two numbers which? In this case is three and then all the volumes you can make up are just multiples of of the greatest common divisor Well, in this case we’re actually out of lucky. He said I was supposed to do a five account to a five There’s no, you know There’s no five anywhere in here that that’s going to work, so I actually have to think of something else I’d probably be dead 30 seconds. I won’t be able to think of anything else

## 100 thoughts on “How not to Die Hard with Math”

1. Turb0 Flat4 says:

A very good algorithm but introducing Bezout's lemma would have made the perfect coda (and would explain why the (6, 15) case won't ever hit 5).

Ur a GENIUS

But why only 60 degrees??? Not any other

4. Luna Alpha Wolf says:

You helped me for summer school for this riddle thank you a lot

5. Sumanto Pal says:

This is coding problem in hackerrank.com named die hard 3

6. Walter Chavez says:

I gave your video a like. How much more difficult would 3+ jugs make the problem?

7. Mort Kebab says:

That isn't a strategy for finding a solution but only for giving a visual representation of the solution once it is found because you have no way of deciding where on the grid to start.

I prefer the intuitive method of saying, "well, I can only fill one container and pour it all, or as much as possible, into the other because that's the only way to know how much I have. And it turns out that you can start either with the 3 or the 5 container filled and either starting point leads to a solution.

8. 運桔 says:

Why it most be on a equilateral triangle grid ?
Does it mean if you have 3 bottles, then you need a square grid¿

9. Jannes L says:

It only works for all solutions if the values of the bottles have no similar prime factors. 🙂

10. Jesus Carl Sancheja says:

can i ask why not just fill 4 gal of water in the 5 gal water jug to end the problem ?

11. angryparrot says:

So I assume if the dimensions are coprime then any volume of water is achievable from one of the starting corners?

12. Peter M says:

The solution I thought of is to fill the 3 gallon, pour it into the 5. Repeat, stopping when the 5 is full – this will leave you with 1 gallon in the 3 tank. Pour that into the 5, fill the 3, pour it into the 5. 1+3=4

13. David Johansson says:

quicker would be to use the 3g to fill the 5 using two of the 3 gallon. then there is 1gal left in the 3 gal. poor out everything in 5gal. then poor the 1 gal into the container and then just fill the 3 gal again to get 4 gallons.

14. Paul G says:

Any guy that likes the Die Hard series is a friend of mine!!

15. Marty Keaton says:

Shareable?

16. Marty Keaton says:

30 seconds?

17. Thor Odinson says:

A) fill 5/5 then pour from it until 3/3 -> we get 2/5, empty 0/3, fill with remainder -> 2/3. fill again 5/5, pour from it until 3/3 -> remainder is 4/5 = win. work: fills: 2 pours:3 empties:1
B) fill 3/3, pour over -> 3/5. fill again 3/3, pour from it until 5/5 -> remainder 1/3. empty 0/5, pour from other so 1/5. add another 3/3 and pour it over -> 4/5 = also win. work: fills: 3 pours:4 empties:1

good vid. you reference all thet hings i like, math, simpsons, futurama, die hard… since i saw the movie i already thought about that a long time ago. 2 solutions come to mind, but i would say its physically impossible, since in 30 filling the jug and being carefully at the same time so you dont splash a little seems impossible for the process required. even with haste… think about it, you probably take around 10 secs to fill your a waterboiler…
anway i liked it in the movie and i like it now 😀 riddles!

18. Carlos Sá says:

this is application in quantum mechanics

19. Dr. Rich says:

Wow! Thank you ?

20. Mikey says:

i think i figured it out in around 30 seconds, i dont think i could physically do the task in less than a minute or so

21. Mikey says:

15gallon jug when full weighs 56kg

22. garyrich2000 says:

The fountain has a steady flow rate and looks like it might be fast enough to fill in 30 seconds.
As an alternative but risky method, count how long to fill the 3 gallon container (x seconds) and use the formula x + x/3 to fill the 5 gallon container to 4 gallons.

23. garyrich2000 says:

If both containers are cube shaped then both containers are filled to a triangle shape in the two dimensional plane without spilling and pour the partial 3 gallon jug into the partial 5 gallon jug. 5/2 + 3/2 = 4

24. Aless Solis says:

How can you still add up 2 gallons to the small container from the big container and still have 2 gallons in the small container… so the size of the small container dosent matter… what's the size measurement difference of the 2 bloody containers. Total B.S. .. not to smart after all.. really ask yourself please ..sorry.

25. Patttriottt - says:

There is another solution!
Place the damn thing under water 😛

26. nekogod says:

Since it's greatest common divisor then presumably that means any 2 prime sized jugs can make any number from 1 to the sum of their sizes, ie a 5 and 17 gallon jug should give you the ability to make any number between 1 and 22?

27. Dracopol says:

You can play with 3 jugs if you draw a 3D pyramid of tetrahedra and ask what happens. You fill a container, you are on one of the edges of the pyramid moving out. Then if you empty the jug, you actually have a choice of going down one face or the other, which corresponds to your choice of emptying water into one of two possible jugs. You have to go on until a jug is filled (maximum coordinate for that jug).
Here is a video of problem with jugs of 12, 8 and 5 litres : can you make 6 litres? (not gallons, but the principle is the same). Can you make any of the amounts from 1 to 12?
The author of the video also talks about the problem in the Die Hard 3 scene.

28. Brian Lotito Ojeda says:

I know I'm late, but… why anyone said anything about his ps1 shirt ? xd

29. Sydney Carton says:

Thanks. My Discrete Mathematics text has the problem of producing 8 units of water given 12 and 17-unit jugs.

30. Sayam Qazi says:

Probably an oversight. They could have dripped water slowly until it reached the required liters volume.

31. Wilson Carmine says:

This puzzle and two similar ones are featured in the final level of Tomb Raider: The Last Revelation. I really liked these puzzles as a kid.

32. KPkiller1671 says:

I wonder if you could extend this problem to more than 2 jugs and if so, extent the billiards table method to higher dimensions 😛

33. Qaer Kyr says:

Fill 5L -> put 5L into 3L -> in 5L remains 2L. empty the 3L, put 2L in 3L, fill 5L, put 1L into 2L (by filling the rest of 1L in 3L jar) from 5L and on the 5L remains 4L.

34. Qaer Kyr says:

Ha nice graph! Very nice way to find the solution!

35. The Egg says:

The Egg was here.

36. Quinnen Crawford says:

i dont think a bomb would be that obvious

37. Build Something says:

I did it a different way. Fill the 3 and put it in the 5. Fill the 3 again and top up the five, leaving 1 in the 3. Empty the five, put the 1 from the 3 in the 5 and then fill the 3 and pour it into the 5, making 4.

38. Gyuszi Suto says:

Great video. What projection technique did you use for your presentation? Is it a projector or a large monitor?

39. S F says:

I'll try to figure it out, but would you describe why you must go all the way to the edges? (Not "because billiard ball must hit edge to bounce" but in terms of the whole methodology).

40. S F says:

Actually, you start at (0,0) (the two empty jugs) then proceed to (5,0). Also you might want to explain why you must start in a corner (each jug must be fully empty or fully filled). How do you extend the method to N jugs?

41. deidara _ says:

Before I watch:
You fill the 3 gallons, and pour it in the 5 gallon; you then fill the 3 gallon again and pour until you've filled the 5 gallon, there is now exactly 1 gallong left in the 3 gallon. You now pour all the contents from the 5 gallon and pour the 1 gallon in it, now fill the remaining 3 gallons in it, you now have exactly 4 gallons of water in the 5-gallon container.

42. K.o.R says:

Chucking the bomb in the fountain would probably have sufficed; the water would absorb a lot of the explosion.

43. Kunal Bhardwaj says:

Sir, You are clearly putting those images in post production, so how exactly are you interacting with those images ? Pl. help me , I am trying to make this type of videos.

44. Trius says:

1. Fill the 5L and pour 3L into the 3L container. There are now 2L remaining in the 5L container.
2. Throw away the water in the 3L container and pour the 2L from the 5L into the 3L container. Now you have room for 1L in the 3L container.
3. Fill the 5L with water again and pour from it 1L into the 3L container which had 2L leaving you with 4 litres in the 5L container.

45. Tim Elsen says:

The Euler characteristic X=1 for a cone, pinched torus or Riemann sphere. Q=2-X=1 gives the # of projective cross caps or Q genus, for 1 sided surfaces. This limit of 2 sided surfaces listed must be 1 sided as H=1-X/2 = 1-1/2 =1/2 would have half a handle or genus. This cone example has no torsion usually present in the homology of 1 sided surfaces, which is possible and this is the only such example I've found. Is this the classical example of a one sided surface having no torsion? Why is this impossible to google? Does this pseudo-manifold require relative homology to deal with the cone vertex singularity or is this all correct as stated above? Does this mean the light cone null space is 1 sided? Continue a normal thru the cone vertex on straight path. For continuity of the normal vector it must pass from the cone interior to exterior when crossing the vertex. Closing the cone in projective 3-D shows the normal stays on the same cone side(interior or exterior)when passing the ideal plane, so the switch of sides when passing straight thru the cone vertex remains intact. THE CONE NULL SPACE OF LIGHT IS 1 SIDED! Passing thru the vertex exchanges spacelike with timelike intervals, as well switching sub-light speed with tachions when moving off the cone surface.

46. Arda Ozkut says:

elegant

47. Lubomir Vlcek says:

SHELLS- SPHERES IN NUCLEI.The Nobel Prize in Physics 1963 Maria Goeppert Mayer, J. Hans D. Jensen,

48. Kathrin Schier says:

Ich liebe es, wie Sie sich immer beömmeln. Sehr schöne Videos.

49. Anton Karlsson says:

you laught cute

50. Hugo Colenbrander says:

From the thumbnail, I thought Bruce Willis was goona giva a math class

51. Mikael Murstam says:

I came up with this solution before the diagram, 0,3 -> 3,0 -> 3,3 -> 5,1 -> 0,1 -> 1,0 -> 1,3 -> 4,0

52. MrDoboz says:

nice, but I would prefer a square based table, where you can travel in 8 directions 45°s apart, and only from edge to edge. Of course, you couldn't use the bottom-left top-right axis unless you had 2 pipes to fill the bottles exactly at the same rate. But you can achieve that with a timer too, so whatever.

53. JaysN says:

1st: Fill up the 3 gallon container.
2nd: Pour the 3 gallons into the 5 gallon container.
3rd: Fill up the 3 gallon container again.
4th: pour as much as possible from the 3 gallon container into the 5 gallon container.
5th: Empty the 5 gallon container.
6th: Pour the rest of the 3 gallon container into the 5 gallon container.
7th: Fill up the 3 gallon container.
8th/Final step: Pour the 3 gallons into the 5 gallon container.

Nice Video!

54. English Luhansk says:

Another way:
(1) fill 3 -> pour them to 5;
(2) fill the 3 again -> pour 2 to 5 = you have 1 left.
(3) empty 5, pour 1 from 3 into 5, fill 3 and pour to 5 = you have 4.

55. Funny vedio Enjoy says:

How complicated problem solve it sir geneous,,☹️??

56. Tech Witch says:

I feel stupid now.

57. Filip Hron says:

I came up with this: Fill up the five gallon with what's in the three gallon, repeat, you have one gallon in three gallon can. Pour out the five gallon, fill it with one gallon from three gallon can, fill the three gallon and pour it t five gallon.

58. kirby urner says:

I can use the diagram to "multiply" the two vectors A, B (at 60 degrees) by then "closing the lid" i.e. edge AB formed by connecting A to B has area = n triangles. Obvious for A times A as you show in another video, but also true for A times B. Extrapolates to A x B x C (three vectors emanating from the corner of a regular tetrahedron). Just "close the lid" and the volume is in "tetravolume" units e.g. 2 x 2 x 5 = 20 tetravolumes. Different meaning of multiplication, but then maths are full of such repurposings.

59. Conor Corrigan says:

Am I the only one who read the title as "How not to Die Hard with Meth"?

60. Walter Chavez says:

Interesting video. How would the solution scale if there were 3 or more jugs?

61. Christian Nafziger says:

fill each full, pour out untill each is half full, then combine, half of 5 is 2.5, half of 3 is 1.5, 2.5 +1.5= 4

62. Didivs Ivlianvs says:

15gb and 6gb to 5 gallons: Fill the 15gb to the top. Cut a small hole near the bottom and let drain into the 6gb while timing and keeping the 15gb top under the fountain so that it stays full. When the 6gb is full, empty it and fill it again for 5/6 the time. 5 gallons exactly.

63. John Lord says:

i solved it differently. I poured 3 gallons into the 5 gallon container, refilled the 3 gallon, poured it into the 5 gallon. That left one gallon. I poured out the 5 gallon container, poured in the one gallon, then poured in three more gallons. Edit: now i've watched the video, i see he showed that one.

64. Nick Prince says:

Make it all into factions.

65. Gyuszi Suto says:

https://youtu.be/jxOa7YMGUMg

66. 4ttyr says:

this is fucking beautiful

Fill the 3 dump in 5, fill the 3 dump in 5 again -> 3 is left with 1L in it. Dump the 5, fill the 5 with the 3 leftover (1L). Fill the 3 dump in 5. 5 is 4 liters.

Science is over-bearing On the other hand, humble and meek Spiritual processes, which no scientific instrument can measure, thank god, are a million times rarer than even a quark or a nano-second particle born of a proton-proton collision. Human mind and related mental capacities, which can be learnt and developed – can see the spiritual processes at work and feel the effect as absolute ecstacy and freedom. But science has swept everybody off their feet with artficial hi-tech junk, and nobody wants to learn spiritual science. Matter science has brain-washed people and they are now slaves of "Time" "Money" and "mathematics". Just talk to a teenager, who has been converted to a timid, matter-enslaved consumer.
For more, go to: ournewscience.com and spend some time reading. Start thinking for yourself. You are a thinker!

69. Mateusz Dobrowolny says:

Really great videos. At the end I missed the conclusion, that once we see that there is a common greatest divisor, we have the same problem in fact as 2 x 5 billiard table.

70. Pan Cogito says:

what is the name of this mathematical constructions ?

71. Eternal Truth says:

Here's an interesting problem for you, you have a 3 and 4 gallon jug, you have 30 seconds and you have to put 8 gallons of water on the computer so it doesn't self destruct. Good Luck!

72. aguaviva says:

fantastic!

73. multi misa says:

well i must comment on this one!! i imagined my self in that scenario and saw the solution in a flash!, fill both the canisters full, pour half from each out, (a tie could be used as a string to determin the half way), 2.5+1.5=4, DONE!

74. davsc64 says:

What if you are using "real" jugs?

75. johnny onthespot says:

I like your disclaimer above Mathologer!

76. Pierre BEYNET says:

Thank you Mathologer for sharing your fun with mathematic.
What about 3 buckets say , 3,5, 7 ? Then a 3 dimensional billard will do. We can see the solution on a 3 dimensional piramidal grid.
What about n buckets with no common divisors, then a n dimensional billard will do…
How to display the the n dimensional grid so that we can "see" the solutions?

77. farooq faizi says:

I like;
my bro, Master Degree Farooq Houston

78. Novotny Ingersol says:

1. Pour the 5 jug into the empty 3 jug leaving 2 in the 5 jug.
2. Dump the 3 jug.
3. Pour the remaining 2 from the 5 jug into the empty 3 jug
4. Fill the 5 jug and top off the 2 gallons in the 3 jug leaving 4 in the 5 jug.

Filling the jugs fast enough in the allotted time is the tricky part.

Wait! Wait! All I have to do is top off the three jug with the…BOOM!

79. Yosef MacGruber says:

Think outside the box. Just have your personal assistant robot calculate the weight of 4 gallons of water, and then have it push on the scale with the same amount of force. Oh wait, this is just an action movie and not a sci-fi (future) movie? I might have to rethink this.

80. OnlyARide says:

But if the jugs are different sizes, that means they'd have different weights. The scale can't tell the difference between 1 ounce of plastic and 1 ounce of water!

81. Rahul Kumar says:

Wow.

82. swampwiz says:

I'll presume the the Mathologer could understand what the terrorists in the first Die Hard were saying in German?

83. weerobot says:

Yippee ki yay Math dude…

84. Davico Rosello says:

These puzzle appears in the Tomb Raider 4 videogame. It have 3 instances, asking for 2, 4 and 1 liter to be measured out of 3 and 5 waterbags.

85. videobuoy buoy says:

Math, WTF is that? you're speaking English, you're European, so you should pronounce it the English way "Maths" math is a bastardisation made by the Americans.

87. raffiking1 says:

I didn't even know there was an alternative solution to the original problem

It's fascinating that the method works, but I would like an explanation of why the figure is a parallelogram. Why does that shape work?

89. elnubnub says:

if you take a cylinder at an angle and fill it until the bottom edge and top edge are at the same water level….then you filled half the cylinder…. so 2.5 +1.5 = 4

Amazing video !
I discovered this type of puzzle when I was young (a long, long time ago) in a book about Sam Loyd's puzzle.
If I remember correctly, he used sometimes a third jug and the diagramm was truncated, but I forgot the details.
Do you know ?

91. nochtczar says:

Wasn't the scene actually from the sequel Die Hard 2?

92. Owen Davies says:

Fill the 3 up, poor it into the 5, fill the three up again, fill as much possible into the five again leaving 1 in the 3 container, empty the 5, put the one into the 5, fill the three again and poor into the 5 so that there’s 4 in the five!

93. Naman Gupta says:

Very very interesting !!!
1. This video
2. Youtube recommending this video after 4 years it's been posted

94. Mauro Amilibia says:

this is too interesting!!!

95. Luke Balgan says:

Great video. Just one problem…

die hard is a christmas movie.

96. Wobblycogs Workshop says:

I wonder if this extends into more dimensions for more jugs?

97. NahDot exe says:

I personally prefer doing it this way: fill the 3 gallon, put it in the 5 gallon, then again fill the 3 gallon, fill the 5 gallon all the way, dump out the 5 gallon, put the 1 gallon (from the 3 gallon) in the 5 gallon, fill the 3 gallon again and you got it.

98. Dave Fashenpour says:

Why Mandelbrot?
​FRACTAL LOG dot COM

99. Pulse Fel says:

so this is best used with primes pretty much

100. Joshua Soh says:

AWESOME VIDEO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!