The Mathologer shares his favourite superingenious method for surviving the type of deadly bucket filling challenge that Bruce Willis and Samuel Jackson face in Die Hard 3. Enjoy!
This is why those fitness types from the gym are always carrying around the 1 gallon jugs of water, JUUUUST in case they get dropped into a Diehard movie.
@@Mathologer If you really think that you have any chance of defeating a villain in a movie, watch the YT video "Why Supervillains Always Keep the Good... " Guy Alive, I think it may be. Good for a laugh. Well at least according to movie logic. They want to be defeated, because once they manage to destroy the world, what then will they do? BTW, I once won a bag of cookies for solving a math puzzle. "Open a combination lock within one minute. Here are the combination numbers, but we didn't bother to tell you what order they come in." I instantly recognized it as a permutations problem. (Or is that combinations? Somebody remind me of the difference?) Choose 1 of 3, 2 of the remaining 2, 1 of the remaining 1. 3! or 6 possible ways to order those numbers. My 4th try opened the lock. Yay! Cookies.
>Fill both half way then dump the 1.5 into the 2.5 Simon says "You've gotto be precise, one ounce more or less will result in detonation." With the irregular jugs he provides filling these jugs exactly half is pretty much impossible. Bruce Willis actually suggests this solution at some point. This approach would work if you are dealing with perfect cylindrical jugs. Can you see how you can fill these exactly halfways?
+Mathologer One ounce tolerance is really tight. Even if the bottles have precise markings for the exact 5 and 3 gallon volumes it is hard. If you put the bottle sideways and try to measure exactly 2.5 gallons, the bottleneck will ruin everything.
+Tapio Hirvikorpi that was the main problem I always had with the bottle ploy. "What constitutes [full]?" Is it when no single drop will fit in the jug? (That's how I would define it, from a scientific standpoint), or are the jugs demarcated in some way--and if they are: How can you be certain the water is at exactly the correct demarcation without a level platform, and some form of linear scale? A 3 gallon jug rarely ever fits exactly 3 gallons and no more, there is almost always room for an air bubble of unknown volume, when there are 3 gallons in said jug (because it would be logistically unfeasible to manufacture, seal and transport the jug efficiently otherwise.)
+Joost Bouten Sideways is okay but you're still eyeballing an unmarked point, along with the already highlighted issue of the neck. For a perfectly cylindrical jug, a better solution would be not sideways but diagonally. If the surface of the water just covers the whole base of the jug and just doesn't cover any of the top surface, you've got half. I.e. looking at it's image side on, you would see a rectangle with the water's surface going corner to corner.
There's another interesting way to examine the solvability of these problems, though not necessarily find an immediate solution. To solve the two bucket challenge, we essentially have two operations: filling a bucket and emptying a bucket. Transferring water from one bucket to another isn't really important for examining solvability as I'll explain. When we fill a bucket initially, we are either filling bucket A (+A) or B (+B). When we transfer without spillage from one bucket to another, we keep the same amount of water, so no expression is needed to keep track of the total amount of water between the two buckets. When we empty a bucket, we are either emptying it from full (-A or -B) or from however much water is in it. However, this latter operation is unnecessary, because if we have a bucket that is not completely full, we have done transferring to reach its special fill value and should not wish to undo our work. So, for the first problem (A = 5 gallon, B = 3 gallon) , we have two particular solutions: The first is to start with a full 5 gallon (+A), pour as much as possible into bucket B (still A amount of water), empty B (A - B), transfer from A to B (still A - B amount of water), fill A again (2A - B), transfer as much as possible from A to B (still 2A - B), then finally empty B again (2A - 2B = 2(5) - 2(3) = 10 - 6 = 4 gallons) The second is to start with a full 3 gallon (+B), pour completely into A (still B amount), fill B again (2B), pour as much as possible into A (still 2B) empty the now full A (-A + 2B), fill B again (-A + 3B) and transfer completely into A (still -A + 3B = -(5) + 3(3) = -5 + 9 = 4). The general solution for this particular scenario is the plane 5x + 3y = z, where x is the number of 5 gallon operations, y is the number of 3 gallon operations and z is the final amount to end up with. Whenever x, y and z are integers, this is potentially solvable, as 5 and 3 are coprime. It requires a bit more effort to find particular solutions, but since integers are closed on addition and multiplication, it is consistent that a sum of products of integers would be an integer. The second problem can be analyzed in the same way. By setting it up as 15x + 6y = 5, since 15 and 6 are not coprime, we can factor and divide to give 5x + 2y = 5/3. This becomes unsolvable if x and y are integers, as a sum of products of integers will only give an integer and never a rational number. Thus there is no solution to the second problem.
You are absolutely right! I once wrote up a little bit of an analysis of what is and what is not possible with the billiards ball method along the lines you are suggesting (for a fun maths course that I am teaching at Monash uni). If you are interested I put it here for you: www.qedcat.com/billiards1.pdf
Isn't the easiest to just fill up A(5 gallons), pour into B(3 gallons), and you're left with 2 gallons. Pour all of B away, move the 2 gallons into B, fill up A, pour enough into B so that it's full, and boom, A has 4 gallons.
Does this have to do with Bezout's identity? It seems like it, but I think it requires z to be the gcd of a and b (5 and 3 here) and just says that there are solutions in Z for ax+by= gcd(a, b).
+Milan Golob > I am curious: is it theoretically possible to solve problem with one infinitely big bottle? (on one side "pool table" would run from 0 to ∞)? >>> Sure, why not. Let's say your remaining finite bottle can hold 5 gallons just like the one in the movie. Then your new table would be bounded by three edges, a horizontal one of length 5 and two parallel infinite rays making 60 degree angles with this horizontal. When you now shoot the billiards ball it will zigzag up the infinite table. This corresponds to you filling the 5 gallon jug over and over and tipping its contents into the infinite bottle. >And why 60° degree angle. >>> Well, just try to imagine what would happen if you left everything in out setup the same but changed the angle. Would things still work out? No, it would not, but other interesting things start happening if you use other specific angles, and these other things can be put to good use to model other interesting problems. For example, a regular rectangular billiards table of integer dimensions n and m can be used to calculate the least common multiple of n and m. B.t.w. the Die Hard setup also calculates the greatest common divisor of n and m. Can you see how?
+Mathologer There is a simler easy way if you do like this: What about Fill 3 Pour 3 gallons into 5 gallon Fill 3 Pour 2 gallons into 5 gallon Empty 5 gallons Pour 1 gallon into 5 gallon Fill 3 gallon Pour 3 gallon into 5 gallon :)
+Mathologer Make a video on the occasions math was wrong. Anyone can appear right when all they do is point out when they were. Make a video on where mathematicians were wrong. I know it would run on for an amazing amount of time. Lets break it down to a quick 20 minutes of historically inaccurate mathematical assumptions to test your humility. Can you admit you can be wrong.
I'm kind of surprised you started at (5,0) or (0,3) on the grid when explaining the process - rather than at (0,0) which presents you with the two initial choices: fill the 3 or fill the 5. Otherwise, as ever, a beautiful solution
I saw that too. You're actually presented with such a "choice" everytime the billiard hits the edge. However, making such a choice always puts you in one of the four corners, reducing the problem to a situation that would have the same result as starting in a corner. Thus, WLOG, we can iterate over running the billiards simulation over the corners without having to worry about making "choices"
Also using a scale to weigh the water means there has to be only one correct solution, as the 5 gallon jug is going to weigh 67% more assuming they're made of the same material
@@Steffystr8mobbin Actually, the 5 gallon jug will be less than 67% heavier. The jug is a thin shell, so its weight depends on its surface area, not the volume it contains. Assuming you keep the same proportions on the jug, scaling up from 3 gallons to 5 gallons only requires (5/3)^(2/3) = 1.41 times as much plastic, i.e., 41% more.
I just realized something, the action of "shooting a billiards ball" can be also said as a series of 3 actions 1) pour the container with the most water into the other container 2) empty the full container 3) fill the empty container For each step, do the action highest up on the list that is possible that doesn't result in backtracking. For the original problem, it looks like this. (0,5) start (3,2) pour biggest -> smallest (0,2) empty full (2,0) pour biggest -> smallest (2,5) fill empty (since pouring again would backtrack) (3,4) pour biggest -> smallest, and we're done!
so you'd need a third jug with a maximum volume that's not divisible by 3 to not Die Hard 25. The easiest way to quickly visualize this is to take a full 15 gallon jug, and just keep filling your mystery third jug with it until this mystery jug is full (doesn't matter how often you have to do this). Then, throw away the third jug because you don't need it anymore; you now have the 15 gallon jug with a volume that is not divisible by 3, allowing you to "shoot the ball" from a side of the table that you couldn't hit before. As long as that number is within the formula 3n+2, it should work; if not, I'm not sure if the mystery jug would work. Another way to visualize it would be to imagine you're in a room that's slanted in both the X and Z axes... in space. With a cue. Firing off a cueball from one corner at an angle I don't even want to try calculating. Now that'd be one hell of a weird game. Personally though, if I were John McClane I'd keep a 1 gallon jug on my person at all times and not bother with all the mental space sports shenanigans.
To be technically correct you need to start at (0,0) every time. But doing this doesn't let you bounce nicely from the bottom right corner. So the rules need to change from strict bouncing when you hit an edge to this: Start at (0,0), then at any point you can choose to go any direction at all provided you follow a line all the way to the edge. Because if you really wanted to, you could go from (0,0) to (5,0) back to (0,0) to (0,3) to (3,0) to (5,0). It breaks the nice billiards analogy, but it works in real life.
Exactly. You could also go from say (2,3) to (0,3) or (5,3). It just wouldn't be productive because you've basically reset the jugs to "easy" values (full or empty).
A great insight! I would add two points: rather than start at 0,5 or 3,0. I would say we assume to start from 0,0. Then the first move is along one edge or the other. That way there's no question about what is an acceptable starting position. Also in the first example you mention that you can get 8 (3+5) but the line didn't touch there. Again, running the ball along the edge shows the appropriate move to make.
Yes, absolutely, it is possible to start at 0,0 and also allow the ball to run along the sides of the table. This gives a complete picture of what can happen and I actually think about the whole setup in this way. However, over the years I've found that when I try to explain this trick to other people I get better results by doing what I did in the video rather than go for the complete picture. I am not sure absolutely sure what it is that confuses people about the complete picture. It could be the red lines running along sides, the way I explain it, ... Anyway, thank you very much for bringing this up.
I agree it add a level of difficultly to the understanding, you'd then need to explain why a red line only counts when it hits a boundary and not all the points in between - in your 6/15 example. And that would just add complexity to your clean and crisp explanation. 😊 I really enjoy your videos - even if the topic is something I think I'm familiar with you always have a fantastic new perspective on it.
I found it helpful to use a Cartesian grid with a 45 degree lines drawn between (0,1) -- (1,0); (0,2) -- (2,0); etc. Basically a deskewed version of this graph. You can create a rectangle for the bounds of the problem. Filling up a jar directly takes you on horizontal or vertical paths. The angled path follows a function which describes volume of one jug going into the other. That is, if you have 5 gal in one jug and slowly pour it into the 3 gallon jug, the volumes follow the straight path between (5,0) and (2,3). It's easy to see why the function has a negative slope. This disrupts the billiard analogy but the difference between filling a jug directly and transferring water is much easier to see.
And you can measure up any volume you want if you have two jars with irrational volume ratio. Well, almost any. To be preicise: A lot, except almost all. But still all you will ever need.
You don't have to draw like 60 degree rhombus. You can draw it like the traditional right angled X-Y grid, which is easier to comprehend the underlying meaning of the graph. X ranges from 0 to 5, Y ranges from 0 to 3. The starting point is (0,0), since both containers are initially empty of course. The traverse lines can be either horizontal, vertical or diagonal, as long as they obey one rule: X and Y must go different directions (e.g. X increases while Y decreases, or X decreases while Y increases; increase/decrease by 0 is accepted). And each traverse line must not stop until it reaches the other outer boundary.
The square graph makes sense in mathematical formulation, but no sense at all when using the physics analogy of a billiard ball bouncing off the table boundary. Also, offering a "choice" of where to go at any given point makes no sense in the real-world application of the bottles. Say you're at 2,3: Choosing to follow along a wall destroys the progress you previously made, by either completely filling or emptying the 5-gallon bottle, which had 2. Now you're at either 0,3, or 5,3, and basically starting over from nothing. You wasted time and the bomb has killed you.
Asking for 4 was actually genious in the original film as you would not have to consider the weight difference of the two containers. If Simon asked for 3 or less there would have been two different weight possible and the bomb would still have a 50/50 chance to explode still with the correct answer.
one way is to fill 3 gal jar and pour in into 5 gal jar and fill the 3 gal jar again and pour in into 5 jar untill you reach 5 gal. you leave with 1 gal in the 3 gal jar. empty the 5 gal and pour 1 gal into 5 gal and refill the 3 gal jar and pour in into 5 gal jar and u get 4.
H it includes more 2 more steps, but 3 gallons fills and empties relatively faster. In a turn based problem, its slower, but in a time based problem, its faster. Its exactly why the shortest route from city A to city B is often not the fastest route.
@@H0A0B123 @ H For ease of math, let us presume 10 seconds per gal transfer time. Step 1: Fill the 5 gal jug 50 seconds Step 2: Pour 3 gal of the 5 gal jug into the empty 3 gal jug 30 seconds Step 3: Empty out the 3 gal jug 30 seconds Step 4: Pour the remaining 2 gals into the 3 gal jug 30 seconds Step 5: Fill the 5 gal jug 50 seconds Step 6: Pour 1 gal of the 5 gal jug into the 3 gal jug 10 seconds Done: The 5 gal jug would have 4 gals 200 seconds Step 1: Fill the 3 gal jug 30 seconds Step 2: Pour 3 gal jug into the empty 5 gal jug 30 seconds Step 3: Fill the 3 gal jug 30 seconds Step 4: Pour 2 gals into the 5 gal jug leaving 1 gal in the 3 gals 20 seconds Step 5: Empty the 5 gal jug 50 seconds Step 6: Pour 1 gal of the 3 gal jug into the 5 gal jug 10 seconds Step 7: Fill the 3 gal jug 30 seconds Step 8: Pour 3 gal jug into the 5 gal jug 30 seconds Done: The 5 gal jug would have 4 gals 230 seconds
This is the one I came up with. Why it physically may be better or worse: The other solution requires 10g from the fountain, 6g poured bottle-to-bottle (5g going 5gb to 3gb and 1g going 3gb to 5gb), and pouring 3g out from the 3gb, a total movement of 19 gallons. This solution requires only 9g from the fountain (good for conservation), 9g poured bottle-to-bottle all from the 3gb to the 5gb, and 5g poured out from the 5gb, a total movement of 23 gallons which in the essence of time would seem to be a disadvantage. First, I note the bottle necks are the same diameter. If the neck of the 5gb were larger, there would be a greater chance of spillage going from the 5gb to 3gb, slowing the process in the other solution. When time is critical, if the fountain is very slow, 9g vs 10g might be an advantage but probably not much. There are also 2 guys to share the work of pouring and filling. The slowest process is going to be bottle-to-bottle since one must be careful not to spill any. The fastest process is emptying bottles on the ground. Other than that, I won't make any precise assumptions or calculate flow rates through openings of a given size. In neither solution can much effective use be made of manpower as there is no opportunity of simultaneous independent operations on the two bottles. That puts this solution at a 4g time disadvantage, all flows being equal. But they are not. This solution's 23g includes 5g of dumping and 18g other, while the other solution has only 3g of dumping and 16g of other, which reduces the time disparity. And 9g from the fountain rather than 10g is a further slight time benefit. Another issue affecting time and care is the amount of weight that must be lifted and handled and in what ways. There is 8.35 pounds to 1 US gallon. In this solution, the full 3gb (25.05 pounds) is lifted and poured bottle-to-bottle 3 times, twice fully and once in 2 stages, between which the 3g bottle may be held ready, offering the only slight opportunity for both men to work together. The 5gb is only dumped and need not be lifted much at all except to put the final 4g (33.4 pounds) on the scale. Total lift is 3x25.05+1x33.4=108.55 pounds. In the other solution, it is the heavier 5gb (41.75 pounds) that is lifted most. Not that these guys are weaklings but the extra weight makes lifting and pouring bottle-to-bottle just a bit slower, more delicate and time-consuming without spilling. This is yet another time disadvantage of the other solution. The 5gb is lifted twice to pour into the 3gb, once in 2 parts between which it may also be held ready as the 3gb is dumped and once to pour 1g into the 3gb. The remaining 4g (33.4 pounds) may be placed directly on the scale. Total lift is 2x41.75=83.5 pounds. Fewer lifts and less total weight probably cancels the ease of handling individual weights, especially for 2 tough guys. Experimentation would be useful if one had the time for multiple trials. But IMO, the other solution, the first presented in the video, has a very slight advantage, somewhat closer than 19-23 in raw gallons moved. Thank you for reading.
I would've used the 5 gallon for displacement instead. fill the 3. pour it in the 5. fill the 3 again pour it in the 5 until full. dump the 5. pour the remaining 1 gallon from the 3 into the 5. fill the 3 again. pour it in. place on scale. And while that sounds like a lot of steps it could be faster since you only move around 9 gallons of water instead of 10. :-P Continued watching and realized you covered this anyways hahaha Love your videos btw
Fill the 5 gallon bucket, then use it to fill the 3 gallon bucket, which would leave 2 gallons of water in the 5 gallon bucket. Mark the water level of the 5 gallon bucket with a marker. Dump the 3 gallon bucket out and pout the leftover 2 gallons from the 5 gallon bucket into the 3 gallon bucket. Fill the 5 gallon bucket to the line that you marked it with, then pour the contents of the 3 gallon bucket back into the 5 gallon bucket. Total = 4 gallons. Took me less than 30 seconds to think of, but it would take more than 30 seconds to execute.
Hu Go - Considering the core math problem here is unit-less - it could just as easily be “fill a jug to 4 liters given a 3 & 5 liter jug” - your reply makes zero sense and comes off as pretentious rather than humorous _(humor needs to play off of reality; you're just combining uncorrelated things)_ . And people wonder why the USA uses different standards of measurements- whenever a non-US-citizen tries to convince us to use Metric, their argument is illogical, non-sensical, and snide! No thank you. In reality, the US is already a dual-measurement country. Metric is used almost universally in sciences, US Customary Units are used more frequently for casual day-to-day measurements, and mechanical/technical fields use either- every hardware store has both US & Metric nuts, screws, bolts; nearly every ruler has both US & Metric measurements, and so on. I won't go into the benefits of the US system here - mainly, how the units are sized to be human-relative rather than atomic-relative and how that makes them less cumbersome for everyday use - but there's clearly benefits to both systems, and we use both.
@@PeteBobGee America's customary measure has drifted significantly from Imperial. A close examination of the history of the Pint is most illustrative en.wikipedia.org/wiki/Pint
@@CapnSlipp imperial is just illogical, in the metric system you basically have a standard unit. size is m, weight is g, and so on. we use si-prefixes (Powers of ten), instead of things like: 1foot = 12 inches. If you want to convert from inches to foot you will be very likely less accurate compared to dm to cm for example.
I just use whatever units that I am given and treat them like variables throughout my calculations, then I do all the unit conversion crap at the very end. =P
@@CapnSlipp in metric, if a unit is not "human sized" you can just use a multiple (as it's done with g->kg) and its not true that imperial (customary) system units are in general more "human sized", for example litres fit better everyday liquid (milk, water...) needs of a human being than gallons. So the only advantage of the consumary system is that people in the US are already habituated to it. There's literally no other advantage.
I would like to thank you a lot for your effort in educating us in such an amazing way. I enjoyed every single video on your channel and I love the way you visually demonstrate all these concepts. You are able to transform something that many times scares and bores so many people into something pleasant and fullfilling. Please, keep posting so we can learn more and more!
Fill the 3 gallon jug (J3) and pour it into the five (J5). Then do it again. You now have 1 gallon left in J3. Empty J5 and pour the one gallon in from J3. Now fill J3 again and pour it in on top - 4 gallons! Thank you, I'm here all week. Edit: then I watched the rest. Oh well. :)
I survived! My solution is different from the one in this video. Fill the 3 gallon, pour it into the 5 gallon, fill the 3 gallon, pour it into the 5 gallon stopping when it is full, leaving 1 gallon in the 3 gallon, empty the 5 gallon, pour the one gallon from the 3 gallon into the 5 gallon, fill the 3 gallon, pour that into the 5 gallon, and you have four gallons in it. The solution given in the video is simpler, but I need to get the job done in 30 seconds! The best answer is *not* required. It took me 17 seconds to devise my answer so I need to really hustle filling and pouring. I have no time to look for a short sequence.When I finish watching the video I see my solution presented at 8:13, but I solved it at the beginning within 30 seconds of being presented with the problem.
One thing you haven't mentioned is that the "rebound" of the red line isn't predetermined; once you hit the border, you can (as in reality) choose the direction among the ones available (and as you explained, every direction represent a specific action, fill or empty one of the jugs, or transfer between the jugs). I was thinking about this because the fact that the plane is skewed seemed to be functional to the rebound, but in the end it's only an aesthetic choice - I imagine determined by the fact that the other diagonal direction (North-East) wouldn'r represent any meaningful action in a non-skewed plane.
Yes, for 2 jars, there are at max 2 interesting directions. Since a rebound requires 1 incoming direction and 1 outgoing direction; the rebound is predetermined. But for n>=3 jars, you can have n(n+1)/2) interesting directions... so there choice comes into play and you the rebound isn't predetermined.
My approach was this: 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!
I got another solution when I tried this myself :) Fill the 3gal, poor it all into the 5gal, fill the 3gal again, poor all from the 3gal into the 5gal until the 5gal is filled, now there is 1gal left in the 3gal, empty the 5gal, poor the 1gal from the 3gal into the 5gal, fill the 3gal again and poor it all into the 5gal and you end up with the 5gal filled with 4gals :P
how would you be sur to have on galon left in the 3 galon container? the first way Matologer shows us is tossing out the unriliable bit and fils the jug to the brim everytime
@@rubenjanssen1672 1: This comment thread is 3 years old, you are lucky to even get a reply from me (as i just watched the video today) 2: Fill the 3 gallon, poor into the 5 gallon; the 5 gal only has space for 2 gal more. fill the 3 gal again and poor into the 5 gal until full, that means you poor exactly 2 gal out of the 3 gal, so your left with exactly 1 gal in the 3 gal container. Empty the 5 gal and put the 1 gal of water in it, now that the 3 gal is empty, you can get 3 gal and add it to the 1 gal of water in the 5 gal, and you have the 4 gallons of water exactly 3: The video even talks about this and shows a visual at 8:10
The incredible feeling of satisfaction this video gave me is exactly why I love math. After all this video is exactly what math actually is. Not numbers and algebra, but something deeper. In the end, "Mathematics is calling different things by the same name" -Henri Poincare
For the DH25 puzzle, Simon might have provided one of the jugs with a specified amount initially. This toughens the puzzle as BW can no longer experiment. Once the initial "pre-loaded" jug has been added to or subtracted from, the initial conditions cannot be replicated. The entire puzzle must be solved in their heads (or on paper if any is available) before pouring into or from the pre-loaded jug. By choosing a jug and initial (partial) amount, the graph can be initialized at any point on the edge. By providing an initial (partial) amount in both jugs, the graph can be started from any interior point as well.
Maybe, for example, he had 2 gal. in one (and only one)? For this to work, in gallons it would just need to be one under a multiple of 3 (because the desired volume is too and the GCF of the container sizes is 3)
In the game Rusty Lake: The Hotel, there is a mini-game in Mr Deer's room which is similar, but with three flasks: 10 dL, 5 dL, and 6 dL. And the goal is to get 8 dL. But there is the added condition that you have exactly 11 dL to work with. This means that you are working within the triangle a+b+c = 11, which turns this 3D puzzle into a 2D puzzle, and you can solve it like above. You have to take some slices off the triangle, to account for the sizes of the flasks. Each corner of the triangle is where there would be 11 in one, and 0 in the other two. So from the Ten corner, slice off a 1by1by1 triangle, from the Five corner, slice off a 6by6by6, and from the Six corner, slice off a 5by5by5. So you're left with a pentagon with corners (10,0,1), (10,1,0), (6,5,0), (0,5,6), (5,0,6). It starts you off on the point (5,0,6). And so you can solve it in the same method as above! (5,0,6)__________(10,0,1) / \ / /(10,1,0) / / / / /___________/ (0,5,6) (6,5,0)
I would really be interested in the visualisation of a harder version of this problem: a 3 dimensional version (3 water containers). Obviously a lot harder, since you can choose one of two paths after hitting every edge, but that just makes it more interesting.
But how would the ball bouncing analogy work? At every point you'll have 2 different routes to go instead of just one. How would you make out a 5 of container sizes 6, 8 and 15?
The analogy could still work -- you just need to imagine you're bouncing off of a 3-d space's walls, rather than a 2-d plane's walls. You can in fact have an indefinite amount of jugs, and the basic principle remains unchanged.
Yes, as long as you have two co-prime containers, you can ignore the rest. But if you fear it will take a long time to reach your target, then using more containers would be beneficial. With 2 jars, there are at max 3 possible actions at any point in the process: 1) Completely fill/empty the first jar, 2) Completely fill/empty the second jar, 3) Completely transfer contents from first to second / second to first jars. That's why Mathologer uses 3 axes in his diagram, to represent the 3 different possible routes. Each action must necessarily either completely deplete (0) the donating body or completely fill (3 or 5) the receiving body or both. Technically, we always start from (0.0); in the first solution, he moved to (5,0) and in the second solution he moved to (0,3) in his first step. In either case, starting from the boundary, we can only move to another point on the boundary and so on. Though we always have 3 options, completely filling/emptying one of the jars would move us to a corner point; which can easily be reached without this complication. So there's actually only 2 interesting directions. By constructing the axes to be 60 deg to each other, he can compare the trajectory of a solution to the bouncing of a billiard ball off walls. With n jars, you'll have at max (n+nC2) routes. So moving from boundary point to boundary point (meaning at least one the jars is either completely empty of completely filled), you can have at max all these n(n+1)/2 routes as interesting when n>=3. For 3 jars, that means 6 interesting directions from a point. Mathologer was able to use the bouncing analogy for 2 jars since there were at max 2 interesting directions; and bouncing requires 1 incoming direction, 1 outgoing direction, and 0 other interesting directions.
You can still use the bouncing algorithm for higher dimensional space; but a single run wouldn't be able to yield the complete solution space. Because for at least one of the points in the trajectory, you'll have multiple directions in which to bounce off.
@Mathologer - you NEED to make an extension of this to explain graph search. I'm a computer science engineer and this can be generalized to a graph search problem and we can use different types of graph search traversals (like BFS/DFS/A* search) to get to a solution from any state to any other state in the most minimal number of moves. The same can be extended to solving Rubik's cube and so on. With A*, you need to create a mathematical heuristic which helps you get to the answer faster.
I could barely even understand the problem when I first saw this movie as a little kid, and I left the movie still not getting what had happened. Flash forward to my present day 17 year old self, and I figured it out in the 30 seconds allotted. Decade younger me would be proud.
@@youcantspellslaughterwitho4353 Germany was founded in 1871. Austria was left over from the part of Bavaria Germany didn't get. There have been 5 famous Austrians: Mozart, Straus, Freud, Swartzenegger and Hitler.
@@angrytedtalks I'd probably add Hundertwasser to the list. And Haydn. Schrödinger. Wittgenstein … Niki Lauda is also quite well-known. And think about royalty … Marie Antoinette was Austrian. But I have to admit they might not be the first one thinks about. Theyʼre famous people, though.
This method is so simple and amazing! I love that your channel is full of interesting stuff like this and you explain things very clearly. So glad to have discovered another great math channel. :)
I paused and had some found another solution :) (don't know if it's in the rest of the video yet) Fill the 3 gallon completely. Empty it into the 5 gallon. Fill the 3 gallon again. Pour all of the available water into the 5 gallon. The 5 gallon only has space for 2 gallons so there will be 1 gallon remaining in the 3. Pour all of the 5 gallon out into the fountain. Pour the 1 gallon from the 3 gallon container into the 5 gallon. Fill the 3 gallon again. Pour the remaining into the 5 gallon. Problem solved!
In general, you can only achieve volumes that can be expressed by mA + nB, where m and n are integers and A and B are the capacity of the containers. In the first case, A = 5 and B = 3, so since you can express 4 as 2*5 - 2*3 (or 3*3 - 1*5), this means that 4 gallons is achievable. 7 gallons is also achievable, since 7 = 2*5 - 1*3 or 4*3 - 1*5. In the second case, A = 15 and B = 6, thus the expression is m*15 + n*6, Since m*15 + n*6 = 3*(m*5 + n*2), no matter what we have inside the parenthesis, the result will always be a multiple of 3. So, we can achieve only multiples of 3 (gallons). Congratulations for your videos. You got a new inscription (from Brazil).
+Paulo Bouhid Glad you like our videos and thank you for saying so. You are absolutely right! I once wrote up a little bit of an analysis of what is and what is not possible with the billiards ball method along the lines you are suggesting (for a fun maths course that I am teaching at Monash uni). If you are interested I put it here for you: www.qedcat.com/billiards1.pdf
+Mathologer I thank you... we all learn something new with your videos, even about subjects we already know. Ans tk you for the link... I´ll take a look. Greetings from Brazil.
I started watching your first Simpsons math video yesterday evening and now I'm here and somehow it's a new day and already getting dark again outside... :-o
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 :D riddles!
You can approach 5 from a 6x3: Empty x & y. Fill x to 6. Fill y ~1/3 full from x so x~5 & label the levels x="5?" & y="1?". Empty y. Fill y to 3 from x so x~2 & label the level "2?". Empty x into y, refill x to "2?", empty y into x & label the doubled level "2*2?". Fill y to "1?". Empty y into x so x~1. Fill y to 3. Empty y into x so x~4. If below "2*2?", "5?">5. If above "2*2?", "5?"
I think, just off the top of my head, if you create your 3 dimensional shape and start at 0,0,0 and choose which direction to start, which equates to filling one of the jugs, that would be a 1 in 3 choice to start. Then I think at every 'bounce' you would have to choose which direction you want to bounce, which equates to which 2 jugs you want to interact with. So it would be a lot more complicated to find a solution. And yes I know this is a 5 year old post.
The Die Hard version is a pretty easy version of the jug puzzle. (Three jugs would probably be harder?) In fact, there's two easy ways to do it. One method would be to fill the 3g, pour it into the 5g, re-fill the 3g, pour all you can into the 5g, empty the 5g, pour the remaining water from the 3g into the 5g, re-fill the 3g, and pour the 3g into the 5g. The other way (which is a few steps shorter and also more intuitive in my opinion) is to fill the 5g, pour all you can into the 3g, empty the 3g, pour the rest of the 5g into the 3g, re-fill the 5g, and pour all you can into the 3g. Either way leaves you with 4g in the 5g jug.
I tried to solve this and I found one more possible sulution : 1) fill the 3 jug 2) pour the 3 gallons to the 5 jug 3) fill the 3 jug again 4) pour as much from 3 jug to 5 jug (there will be 1 gallon left in 3 jug) 5) empty the 5 jug 6) pour the 1 gallon to the 5 jug 7) fill the 3 jug again 8) pour the 3 gallons from the 3 jug to 5 jug (And now you have 4 gallons in 5 jug) Or just buy 4 gallons jug :D
Alternatively, you could pour a full three gallon into the five, then refill the three and pour into the five until you just fill the five to max. Now you have exactly one gallon in the small jug. Completely dump the five to fully empty and then pour in the one gallon from the small jug into the five. Then pour a full three into the five and you have four gallons. There's more than one way to get the answer, but if a timer on a bomb is ticking down... who knows how well one could concentrate if this were to actually happen.
Let a and b with a>b be the sizes of the jugs. When you pour water between them the total water quantity changes by one of +a, +b, -a, -b so the water quantity changes by +b or -b mod a. That means the quantities that can be obtained in the jug a are the elements of the subgroup generated by b in (Z_a, +), that is, all the multiples of gcd(a,b) ( mod a )
These two-jug problems can look difficult, but they are almost impossible *not* to solve. Fill either one, then keep doing the only thing you can do that isn't backtracking until you're done. It's modular division.
I guess I'm the only one who would notice things like the difference in the weight of the two containers would be more than an ounce, so if a variation of one ounce causes the bomb to go off, there's a chance you're getting blown up even if you manage to get the 2 gallons exactly (depending on which container he used when accounting for the weight. More importantly, mass production containers (which those clearly are), will never be "exactly 3 gallons" and "exactly 5 gallons". If you get a 3 gallon container, it is 3 gallons plus a certain amount of extra air space (and in this situation, you don't know that amount). For this to be in any way practical, you'd need bespoke containers, or at least have drawn on lines showing the fill levels (in which case you're going to run out of time trying to get them filled exactly to that point). So yeah, no matter what, short of blind luck, you're getting blown up.
For the entire video I was wondering if there is a combination of water tanks for which some solutions are impossible. It's great that you tackled this question at the end of the video as well ;)
I prefer starting with the 3 gallon jug - filling it up and emptying it in the 5 gallon jug. Do that again so the 5 gallon jug is full leaving 1 gallon in the 3 gallon jug. Empty the 5 gallon jug and then put the 1 gallon from the 3 jug into the empty 5 gallon jug. refill the 3 gallon and put it into the 1 gallon in the 5 gallon jug and you have 4 gallons.
I have a different solution for the water problem (before watching the diagram explanation): - Fill 3 gallon container - Pour it over into the 5 gallon container - Repeat, which will leave 1 gallon in the 3 gallon container - Empty 5g container and empty 1g from the 3g container into 5g container - Fill 3g container and pour it into the 5g container, which will result in 4g as well
Proof that you can always obtain any number divisible by gcd(A,B): Suppose A > B. Then filling up the A bucket and repeatedly transferring to the B bucket and dumping corresponds to repeatedly subtracting B from A, so we end up with R
The state machine like approach is quite interesting... I also looked your hidden cube in simpsons video which also has a state machine approach. Really nice videos :)
I worked out the second way, fill the 5l jug twice leaving 1l in the 3l jug. For the 15l jug you could poke a hole and time how long it takes to empty. Then calculate how long it would take for the relevant amount to drain, leaving the required amount. Given that you only have 30 seconds, perhaps you could cut the whole bottom off.
I've binge watched about half of your videos now and this one is my absolute favourite so far (which says a lot since all of them are amazing). I'd love it if you made another video about the "table" where you go more in depth into it. Maybe there are ones with different shapes that work with more than two bottles? Hexagons?
Great, glad you like this one so much :) I've been thinking about building a physical table whose sides are made from mirrors and such that two of these mirror (up and right) can be moved to make tables of different sizes. Then replacing the billiards ball by a laser beam would make for a nice analog computer for calculating the gcd of two integers.
Mathologer Wow, you might not believe me but I had the same idea while watching the video. You just have to cover the piece of mirror with the desired result and you have your route. You might also need some smoke. Looking forward to this.
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.
This is my solution after watching the scene and in my opinion it was a breeze. Fill the 5 gallon jug then pour from the 5 gallon jug into the 3 gallon jug until the 3 gallon jug is full. Empty the 3 gallon jug and then pour the remaining 2 gallons from the 5 gallon jug into the 3 gallon jug. Lastly fill the 5 gallon jug up once more and pour from it into the 3 gallon jug until the three gallon jug is full. Since the 3 gallon jug already contained 2 gallons at this point you will have poured over 1 gallon of water and the 5 gallon jug will contain 4 gallons of water. Edit: I see that you solved it in the same way :D
You may also think of this as a regular Cartesian coordinate grid with the diagonals being lines of the form x + y = n where n is an integer. So (x,y) are your amounts in the jugs and since you can only start with one jug full, the solutions must always be integers. n is how much water you have total. The verticals and horizontals are just the actions of entirely filling an empty jug or emptying a jug that is already full.
You can only touch each node if both numbers are prime. When you add or subtract them, you get remainders that aren't shared factors or divisible numbers. Any other combinations of non prime will lead to paradox
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.
for 1 gallon you could fill the 3 and poor it into the 5, then do that again and you will have 1 gallon left for the scales. for 2 you just fill the five and poor into the 3
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.
In the case of any quantity of liquid that is less than or equal to 3, the choice of which container you will use becomes relevant. With greater than 3 gallons and less than or equal to 5 gallons it is implied that you must use the larger container, and thus you would expect the weight of the container itself + that many gallons would be what the scale is tuned to measure. With less, using the wrong container would lead to your death because weight of the containers themselves also contributes to the weight. If it is tuned to weigh, for example, 2 gallons in the smaller container but you used 2 gallons in the larger container, boom. If it is tuned to 2 gallons in the larger container and you used 2 gallons in the smaller container, boom. There is only a clear choice for the higher range of values, unless you pretend that the containers weigh less than an ounce, as that's the tolerance that was communicated. Per google, an empty 5 gallon jug weighs about 12oz and a 3 gallon weighs about 8oz. Oddly, in the clip he also states to put the 4 gallons in "one of the containers" implying either one would work. That would only make sense if there were two different valid ranges of weights that would be accepted by the scale.
One more observation that I'm not sure was covered in the video or the comments. This puzzle is solvable for 4 gallons because 3 and 5 are relatively prime. And so n*3 modulo 5 will eventually produce every gallon increment from 0 to 5 for some n ranging from 0 to 4. Knowing this, we also are able to deduce, among many possibilities, that we could produce every gallon increment with a 15 gallon container coupled with a {1, 2, 4, 7, 8, 11, 13, and 14} gallon container, or even beyond this such as {16, 17, 19, 22, 23, 26, 28, ...} because these numbers share no common prime factors with 15.
Nevermind. After a deeper search, I notice a few people over the years have made similar observations already, and have had them confirmed by Mathologer. Great video!
Solved that in ten seconds by filling the 5 gallon jug with 2x 3 gallon jugs and then emptying the 5 gallon jug, leaving you with 1 gallon in the 3 gallon jug. Then empty the 1 gallon into the 5 gallon jug and adding another 3 gallons from the 3 gallon jugs. Solved.
Let's have an urn with 3,5, and 8 different colour marbles. Let's draw 8 marbles from the urn. The cases of the distribution we get are isomorphic to the states on the first billiard table. The last parameter can be greater than 8, it's water in the tap. When we empty a jug we're putting water back into the "tap". Also, this shows how to generalize the problem and solve ones with more than two jugs.
axxization Yes, absolutely all this generalizes nicely in a couple of different ways: replace the tap by a third jug fully or partly filled with water, add more jugs, and so on. And for some of these generalizations what I talk in the video can be adapted. If you are interested in finding out more google "decanting problems".
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.
@2:15 "I think anybody who actually thinks about this a little bit will come up with this solution" I thought first of another solution where mostly the 3-gal jug is moved (which is easier): Fill 3-gal jug and pour all the water into 5-gal jug. Fill 3-gal jug again and pour water into 5-gal jug until full. Then 1 gallon is left in 3-gal jug. Pour out 5-gal jug (only one move with this jug) and fill the 1 gallon into 5-gal jug. Fill 3-gal jug and pour all the water into 5-gal. Now, there are 4 gallons in the 5-gal jug.
At the end, it seems like we can prepare any volume in full gallons if and only of the two volumes in gallons do NOT share a common divisor larger than 1. If they share a divisor larger than 1, like 2 or 3, then we can make prepare only volumes of multiple of that common divisor in gallons. Nice diagram.
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?
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.
I gotta say, this would be more intuitive if you used a rectilinear system. The box would be 5 by 3, with diagonals running down at a -1 slope. Then a vertical or horizontal line represent filling or emptying one of the bottles, while a diagonal means transferring from one bottle into the other (hence the total amount of water, x + y, remains constant). At each intersection you can choose to travel horizontally, vertically, or along a downward diagonal but you cannot stop until you reach the edge of a box, meaning one bottle is completely full or completely empty.
I worked it as fill the 3, pour into the 5, 2 space left in 5, refill the 3, pour into 5, 1 left in 3, empty 5, put 1 from 3 to 5, refill 3, pour into 5
Given N jugs, is there an analogous N-dimensional graph that tells you the solution(s) or does that introduce a >1 branching factor making it a harder problem?
After 12:30 ... Okay, I would pay ANY ticket price to see John McLean match wits with an evil, twisted genius with a German accent played by the Mathologer! Let's make it happen!
It may be more steps, but i thought of a different way before watching the rest of the video. Fill the 3 gallon, then dump it into the 5. Fill the 3 again and dump it into the 5 leaving the 1 gallon left over. Dump the 5, then put the 1 gallon into the 5 gallon container. Then fill the 3 gallon and add it to the 1.
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.
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.
Turn each bucket on a 45 degree angle. Fill both containers until the water level forms a diagonal. The container will be exactly half full. 1/2(5 +3) = 4
+Rosa Lyn Good idea. Probably won't work with the containers that they are dealing with in the movie though. For your trick to work you would need cylindrical containers :)
1:40 fill 5 gallon(leaving 2 gallons) pour into 3 gallon. DISCARD 3 gallons. pour remaining from 5 gal into 3 gallon refil 5 gallon. finish filling 3 gallons (currently holds 2 gallons, 2+1=3) with 5 gallon jug. 5 gallon jug now contains 4 gallons 5-1=4
thanks, i was always thinking how they've done it cause i came up with a different solution that works as well. fill 3 gallon bottle and pour all in 5 gallon bottle. then again fill 3 gallon bottle and fill the rest of the 5 gallon from the 3 gallon bottle. then you will have 1 gallon remaining in the 3 gallon bottle. pour the 5 gallon bottle out and fill that remaining 1 gallon in the empty 5 gallon bottle. the fill the 3 gallon bottle and pour all in the 5 gallon bottle. and then you have it. :-)
By the way, Simon dies. He's in a helicopter with his girlfriend and McClane shoots out the power line above it causing it to tangle into the rotor and making the helicopter crash into a fireball.
Great video. I really enjoyed the mathematical billiards explanation, quite amazing.
Wow, fancy seeing you here...
MindYourDecisions wow, you watch someone else i know
MindYourDecisions Didn't expect to see you commenting, hello there!
wow fancy seeing you here
I completely read that comment with your voice.
This is why those fitness types from the gym are always carrying around the 1 gallon jugs of water, JUUUUST in case they get dropped into a Diehard movie.
You should be the next villain in a Die Hard movie, throwing all kinds of math puzzles at the heroes :)
mishmosh77 Can you nominate me :)
Nah, he should play the Riddler!
@@Mathologer
If you really think that you have any chance of defeating a villain in a movie, watch the YT video "Why Supervillains Always Keep the Good... " Guy Alive, I think it may be. Good for a laugh. Well at least according to movie logic. They want to be defeated, because once they manage to destroy the world, what then will they do?
BTW, I once won a bag of cookies for solving a math puzzle. "Open a combination lock within one minute. Here are the combination numbers, but we didn't bother to tell you what order they come in." I instantly recognized it as a permutations problem. (Or is that combinations? Somebody remind me of the difference?) Choose 1 of 3, 2 of the remaining 2, 1 of the remaining 1. 3! or 6 possible ways to order those numbers. My 4th try opened the lock. Yay! Cookies.
@@yosefmacgruber1920 Yea... remembering this from yearrs back from "Megamind"
>Fill both half way then dump the 1.5 into the 2.5
Simon says "You've gotto be precise, one ounce more or less will result in detonation." With the irregular jugs he provides filling these jugs exactly half is pretty much impossible. Bruce Willis actually suggests this solution at some point. This approach would work if you are dealing with perfect cylindrical jugs. Can you see how you can fill these exactly halfways?
Mathologer Just put the jugs sideways and see if the water passes the middle of the cylinder :D
Joost Bouten Exactly :)
+Mathologer One ounce tolerance is really tight. Even if the bottles have precise markings for the exact 5 and 3 gallon volumes it is hard. If you put the bottle sideways and try to measure exactly 2.5 gallons, the bottleneck will ruin everything.
+Tapio Hirvikorpi that was the main problem I always had with the bottle ploy. "What constitutes [full]?"
Is it when no single drop will fit in the jug? (That's how I would define it, from a scientific standpoint), or are the jugs demarcated in some way--and if they are: How can you be certain the water is at exactly the correct demarcation without a level platform, and some form of linear scale?
A 3 gallon jug rarely ever fits exactly 3 gallons and no more, there is almost always room for an air bubble of unknown volume, when there are 3 gallons in said jug (because it would be logistically unfeasible to manufacture, seal and transport the jug efficiently otherwise.)
+Joost Bouten Sideways is okay but you're still eyeballing an unmarked point, along with the already highlighted issue of the neck. For a perfectly cylindrical jug, a better solution would be not sideways but diagonally. If the surface of the water just covers the whole base of the jug and just doesn't cover any of the top surface, you've got half. I.e. looking at it's image side on, you would see a rectangle with the water's surface going corner to corner.
There's another interesting way to examine the solvability of these problems, though not necessarily find an immediate solution.
To solve the two bucket challenge, we essentially have two operations: filling a bucket and emptying a bucket. Transferring water from one bucket to another isn't really important for examining solvability as I'll explain.
When we fill a bucket initially, we are either filling bucket A (+A) or B (+B). When we transfer without spillage from one bucket to another, we keep the same amount of water, so no expression is needed to keep track of the total amount of water between the two buckets.
When we empty a bucket, we are either emptying it from full (-A or -B) or from however much water is in it. However, this latter operation is unnecessary, because if we have a bucket that is not completely full, we have done transferring to reach its special fill value and should not wish to undo our work.
So, for the first problem (A = 5 gallon, B = 3 gallon) , we have two particular solutions:
The first is to start with a full 5 gallon (+A), pour as much as possible into bucket B (still A amount of water), empty B (A - B), transfer from A to B (still A - B amount of water), fill A again (2A - B), transfer as much as possible from A to B (still 2A - B), then finally empty B again (2A - 2B = 2(5) - 2(3) = 10 - 6 = 4 gallons)
The second is to start with a full 3 gallon (+B), pour completely into A (still B amount), fill B again (2B), pour as much as possible into A (still 2B) empty the now full A (-A + 2B), fill B again (-A + 3B) and transfer completely into A (still -A + 3B = -(5) + 3(3) = -5 + 9 = 4).
The general solution for this particular scenario is the plane 5x + 3y = z, where x is the number of 5 gallon operations, y is the number of 3 gallon operations and z is the final amount to end up with.
Whenever x, y and z are integers, this is potentially solvable, as 5 and 3 are coprime. It requires a bit more effort to find particular solutions, but since integers are closed on addition and multiplication, it is consistent that a sum of products of integers would be an integer.
The second problem can be analyzed in the same way. By setting it up as 15x + 6y = 5, since 15 and 6 are not coprime, we can factor and divide to give 5x + 2y = 5/3. This becomes unsolvable if x and y are integers, as a sum of products of integers will only give an integer and never a rational number. Thus there is no solution to the second problem.
You are absolutely right! I once wrote up a little bit of an analysis of what is and what is not possible with the billiards ball method along the lines you are suggesting (for a fun maths course that I am teaching at Monash uni). If you are interested I put it here for you: www.qedcat.com/billiards1.pdf
Isn't the easiest to just fill up A(5 gallons), pour into B(3 gallons), and you're left with 2 gallons. Pour all of B away, move the 2 gallons into B, fill up A, pour enough into B so that it's full, and boom, A has 4 gallons.
Does this have to do with Bezout's identity? It seems like it, but I think it requires z to be the gcd of a and b (5 and 3 here) and just says that there are solutions in Z for ax+by= gcd(a, b).
Well... I'm a mathemitician and I like action movies.
Concise and straight to the point :)
@Bob Trenwith I was quoting the guy in the video!!! Did you even watch it or are you just looking to complain?
@Bob Trenwith No, just claiming that you're a douche. Which is evident.
As soon as he put the coordinates I breathed out and just thought "that's brilliant"
Michael, glad you like this video but please don't disable the reply button if you'd like me to reply to questions in your comments :)
+Mathologer Ok. i guess? :)
+Milan Golob > I am curious: is it theoretically possible to solve problem with one infinitely big bottle? (on one side "pool table" would run from 0 to ∞)?
>>> Sure, why not. Let's say your remaining finite bottle can hold 5 gallons just like the one in the movie. Then your new table would be bounded by three edges, a horizontal one of length 5 and two parallel infinite rays making 60 degree angles with this horizontal. When you now shoot the billiards ball it will zigzag up the infinite table. This corresponds to you filling the 5 gallon jug over and over and tipping its contents into the infinite bottle.
>And why 60° degree angle.
>>> Well, just try to imagine what would happen if you left everything in out setup the same but changed the angle. Would things still work out? No, it would not, but other interesting things start happening if you use other specific angles, and these other things can be put to good use to model other interesting problems. For example, a regular rectangular billiards table of integer dimensions n and m can be used to calculate the least common multiple of n and m. B.t.w. the Die Hard setup also calculates the greatest common divisor of n and m. Can you see how?
+Mathologer There is a simler easy way if you do like this:
What about
Fill 3
Pour 3 gallons into 5 gallon
Fill 3
Pour 2 gallons into 5 gallon
Empty 5 gallons
Pour 1 gallon into 5 gallon
Fill 3 gallon
Pour 3 gallon into 5 gallon
:)
+nikolaj møller it was the second solution.
+Mathologer Make a video on the occasions math was wrong. Anyone can appear right when all they do is point out when they were. Make a video on where mathematicians were wrong. I know it would run on for an amazing amount of time. Lets break it down to a quick 20 minutes of historically inaccurate mathematical assumptions to test your humility. Can you admit you can be wrong.
I readed "How to Die Hard with Math", i clicked it.
Calculus kills me everytime.
I'm kind of surprised you started at (5,0) or (0,3) on the grid when explaining the process - rather than at (0,0) which presents you with the two initial choices: fill the 3 or fill the 5. Otherwise, as ever, a beautiful solution
I saw that too. You're actually presented with such a "choice" everytime the billiard hits the edge. However, making such a choice always puts you in one of the four corners, reducing the problem to a situation that would have the same result as starting in a corner. Thus, WLOG, we can iterate over running the billiards simulation over the corners without having to worry about making "choices"
Also using a scale to weigh the water means there has to be only one correct solution, as the 5 gallon jug is going to weigh 67% more assuming they're made of the same material
@@Steffystr8mobbin Both solutions end up with four gallons in the five gallon jug
@@Steffystr8mobbin There is no way you can have 4 gallons in the 3-gallon jug
@@Steffystr8mobbin Actually, the 5 gallon jug will be less than 67% heavier. The jug is a thin shell, so its weight depends on its surface area, not the volume it contains. Assuming you keep the same proportions on the jug, scaling up from 3 gallons to 5 gallons only requires (5/3)^(2/3) = 1.41 times as much plastic, i.e., 41% more.
I just realized something, the action of "shooting a billiards ball" can be also said as a series of 3 actions
1) pour the container with the most water into the other container
2) empty the full container
3) fill the empty container
For each step, do the action highest up on the list that is possible that doesn't result in backtracking. For the original problem, it looks like this.
(0,5) start
(3,2) pour biggest -> smallest
(0,2) empty full
(2,0) pour biggest -> smallest
(2,5) fill empty (since pouring again would backtrack)
(3,4) pour biggest -> smallest, and we're done!
Neat- just in case you don't have the iso grid "pool table" handy!
so you'd need a third jug with a maximum volume that's not divisible by 3 to not Die Hard 25.
The easiest way to quickly visualize this is to take a full 15 gallon jug, and just keep filling your mystery third jug with it until this mystery jug is full (doesn't matter how often you have to do this). Then, throw away the third jug because you don't need it anymore; you now have the 15 gallon jug with a volume that is not divisible by 3, allowing you to "shoot the ball" from a side of the table that you couldn't hit before. As long as that number is within the formula 3n+2, it should work; if not, I'm not sure if the mystery jug would work.
Another way to visualize it would be to imagine you're in a room that's slanted in both the X and Z axes... in space. With a cue. Firing off a cueball from one corner at an angle I don't even want to try calculating.
Now that'd be one hell of a weird game.
Personally though, if I were John McClane I'd keep a 1 gallon jug on my person at all times and not bother with all the mental space sports shenanigans.
:)
WHAT IS THE DIAGRAM CALLED.I SEARCH AND LEARN
or the villains evil doctor Simpson!
... what??
To be technically correct you need to start at (0,0) every time. But doing this doesn't let you bounce nicely from the bottom right corner. So the rules need to change from strict bouncing when you hit an edge to this: Start at (0,0), then at any point you can choose to go any direction at all provided you follow a line all the way to the edge. Because if you really wanted to, you could go from (0,0) to (5,0) back to (0,0) to (0,3) to (3,0) to (5,0). It breaks the nice billiards analogy, but it works in real life.
Absolutely :)
Exactly. You could also go from say (2,3) to (0,3) or (5,3). It just wouldn't be productive because you've basically reset the jugs to "easy" values (full or empty).
A great insight!
I would add two points: rather than start at 0,5 or 3,0. I would say we assume to start from 0,0. Then the first move is along one edge or the other. That way there's no question about what is an acceptable starting position.
Also in the first example you mention that you can get 8 (3+5) but the line didn't touch there. Again, running the ball along the edge shows the appropriate move to make.
Yes, absolutely, it is possible to start at 0,0 and also allow the ball to run along the sides of the table. This gives a complete picture of what can happen and I actually think about the whole setup in this way. However, over the years I've found that when I try to explain this trick to other people I get better results by doing what I did in the video rather than go for the complete picture. I am not sure absolutely sure what it is that confuses people about the complete picture. It could be the red lines running along sides, the way I explain it, ... Anyway, thank you very much for bringing this up.
I agree it add a level of difficultly to the understanding, you'd then need to explain why a red line only counts when it hits a boundary and not all the points in between - in your 6/15 example. And that would just add complexity to your clean and crisp explanation. 😊
I really enjoy your videos - even if the topic is something I think I'm familiar with you always have a fantastic new perspective on it.
Haha, came to the comments to say the same :D
@@Mathologer
you can draw dots whenever the current position reaches another by following a straight line instead of tracing the entire line
I found it helpful to use a Cartesian grid with a 45 degree lines drawn between (0,1) -- (1,0); (0,2) -- (2,0); etc. Basically a deskewed version of this graph. You can create a rectangle for the bounds of the problem. Filling up a jar directly takes you on horizontal or vertical paths. The angled path follows a function which describes volume of one jug going into the other. That is, if you have 5 gal in one jug and slowly pour it into the 3 gallon jug, the volumes follow the straight path between (5,0) and (2,3). It's easy to see why the function has a negative slope. This disrupts the billiard analogy but the difference between filling a jug directly and transferring water is much easier to see.
You can choose any two coprime numbers in order to make it possible to hit every point on your "billiards table" :)
Correct :)
And you can measure up any volume you want if you have two jars with irrational volume ratio.
Well, almost any.
To be preicise: A lot, except almost all.
But still all you will ever need.
Mathologer i think it might work with any size containers which don’t have common factors
@@guestuser2373
yes, that's what 'co-prime' means
You don't have to draw like 60 degree rhombus. You can draw it like the traditional right angled X-Y grid, which is easier to comprehend the underlying meaning of the graph.
X ranges from 0 to 5, Y ranges from 0 to 3. The starting point is (0,0), since both containers are initially empty of course.
The traverse lines can be either horizontal, vertical or diagonal, as long as they obey one rule: X and Y must go different directions (e.g. X increases while Y decreases, or X decreases while Y increases; increase/decrease by 0 is accepted). And each traverse line must not stop until it reaches the other outer boundary.
The square graph makes sense in mathematical formulation, but no sense at all when using the physics analogy of a billiard ball bouncing off the table boundary. Also, offering a "choice" of where to go at any given point makes no sense in the real-world application of the bottles. Say you're at 2,3: Choosing to follow along a wall destroys the progress you previously made, by either completely filling or emptying the 5-gallon bottle, which had 2. Now you're at either 0,3, or 5,3, and basically starting over from nothing. You wasted time and the bomb has killed you.
Asking for 4 was actually genious in the original film as you would not have to consider the weight difference of the two containers. If Simon asked for 3 or less there would have been two different weight possible and the bomb would still have a 50/50 chance to explode still with the correct answer.
Two jugs of different capacities could still weigh the same. 😛
Maybe the masses of the jugs were negligible.
one way is to fill 3 gal jar and pour in into 5 gal jar and fill the 3 gal jar again and pour in into 5 jar untill you reach 5 gal. you leave with 1 gal in the 3 gal jar. empty the 5 gal and pour 1 gal into 5 gal and refill the 3 gal jar and pour in into 5 gal jar and u get 4.
yeh that's how i did it, and it's faster
he showed both solutions. and i don't think this is faster
H it includes more 2 more steps, but 3 gallons fills and empties relatively faster. In a turn based problem, its slower, but in a time based problem, its faster.
Its exactly why the shortest route from city A to city B is often not the fastest route.
@@H0A0B123 @ H
For ease of math, let us presume 10 seconds per gal transfer time.
Step 1: Fill the 5 gal jug 50 seconds
Step 2: Pour 3 gal of the 5 gal jug into the empty 3 gal jug 30 seconds
Step 3: Empty out the 3 gal jug 30 seconds
Step 4: Pour the remaining 2 gals into the 3 gal jug 30 seconds
Step 5: Fill the 5 gal jug 50 seconds
Step 6: Pour 1 gal of the 5 gal jug into the 3 gal jug 10 seconds
Done: The 5 gal jug would have 4 gals 200 seconds
Step 1: Fill the 3 gal jug 30 seconds
Step 2: Pour 3 gal jug into the empty 5 gal jug 30 seconds
Step 3: Fill the 3 gal jug 30 seconds
Step 4: Pour 2 gals into the 5 gal jug leaving 1 gal in the 3 gals 20 seconds
Step 5: Empty the 5 gal jug 50 seconds
Step 6: Pour 1 gal of the 3 gal jug into the 5 gal jug 10 seconds
Step 7: Fill the 3 gal jug 30 seconds
Step 8: Pour 3 gal jug into the 5 gal jug 30 seconds
Done: The 5 gal jug would have 4 gals 230 seconds
This is the one I came up with. Why it physically may be better or worse: The other solution requires 10g from the fountain, 6g poured bottle-to-bottle (5g going 5gb to 3gb and 1g going 3gb to 5gb), and pouring 3g out from the 3gb, a total movement of 19 gallons. This solution requires only 9g from the fountain (good for conservation), 9g poured bottle-to-bottle all from the 3gb to the 5gb, and 5g poured out from the 5gb, a total movement of 23 gallons which in the essence of time would seem to be a disadvantage. First, I note the bottle necks are the same diameter. If the neck of the 5gb were larger, there would be a greater chance of spillage going from the 5gb to 3gb, slowing the process in the other solution. When time is critical, if the fountain is very slow, 9g vs 10g might be an advantage but probably not much. There are also 2 guys to share the work of pouring and filling. The slowest process is going to be bottle-to-bottle since one must be careful not to spill any. The fastest process is emptying bottles on the ground. Other than that, I won't make any precise assumptions or calculate flow rates through openings of a given size. In neither solution can much effective use be made of manpower as there is no opportunity of simultaneous independent operations on the two bottles. That puts this solution at a 4g time disadvantage, all flows being equal. But they are not. This solution's 23g includes 5g of dumping and 18g other, while the other solution has only 3g of dumping and 16g of other, which reduces the time disparity. And 9g from the fountain rather than 10g is a further slight time benefit. Another issue affecting time and care is the amount of weight that must be lifted and handled and in what ways. There is 8.35 pounds to 1 US gallon. In this solution, the full 3gb (25.05 pounds) is lifted and poured bottle-to-bottle 3 times, twice fully and once in 2 stages, between which the 3g bottle may be held ready, offering the only slight opportunity for both men to work together. The 5gb is only dumped and need not be lifted much at all except to put the final 4g (33.4 pounds) on the scale. Total lift is 3x25.05+1x33.4=108.55 pounds. In the other solution, it is the heavier 5gb (41.75 pounds) that is lifted most. Not that these guys are weaklings but the extra weight makes lifting and pouring bottle-to-bottle just a bit slower, more delicate and time-consuming without spilling. This is yet another time disadvantage of the other solution. The 5gb is lifted twice to pour into the 3gb, once in 2 parts between which it may also be held ready as the 3gb is dumped and once to pour 1g into the 3gb. The remaining 4g (33.4 pounds) may be placed directly on the scale. Total lift is 2x41.75=83.5 pounds. Fewer lifts and less total weight probably cancels the ease of handling individual weights, especially for 2 tough guys. Experimentation would be useful if one had the time for multiple trials. But IMO, the other solution, the first presented in the video, has a very slight advantage, somewhat closer than 19-23 in raw gallons moved. Thank you for reading.
I never knew this kind of problems had such a enormously enlightening picture as this one. GREAT JOB!!!!!!!!!!!!
This channel deserves definitely more likes and subscriptions.
I would've used the 5 gallon for displacement instead. fill the 3. pour it in the 5. fill the 3 again pour it in the 5 until full. dump the 5. pour the remaining 1 gallon from the 3 into the 5. fill the 3 again. pour it in. place on scale. And while that sounds like a lot of steps it could be faster since you only move around 9 gallons of water instead of 10. :-P
Continued watching and realized you covered this anyways hahaha Love your videos btw
Fill the 5 gallon bucket, then use it to fill the 3 gallon bucket, which would leave 2 gallons of water in the 5 gallon bucket. Mark the water level of the 5 gallon bucket with a marker. Dump the 3 gallon bucket out and pout the leftover 2 gallons from the 5 gallon bucket into the 3 gallon bucket. Fill the 5 gallon bucket to the line that you marked it with, then pour the contents of the 3 gallon bucket back into the 5 gallon bucket. Total = 4 gallons. Took me less than 30 seconds to think of, but it would take more than 30 seconds to execute.
+ByRecentDesign yeah because everybody ever has a marker handy at times like those
"How not to Die Hard with Math"
Simple answer: use the metric system.
Hu Go - Considering the core math problem here is unit-less - it could just as easily be “fill a jug to 4 liters given a 3 & 5 liter jug” - your reply makes zero sense and comes off as pretentious rather than humorous _(humor needs to play off of reality; you're just combining uncorrelated things)_ .
And people wonder why the USA uses different standards of measurements- whenever a non-US-citizen tries to convince us to use Metric, their argument is illogical, non-sensical, and snide! No thank you.
In reality, the US is already a dual-measurement country. Metric is used almost universally in sciences, US Customary Units are used more frequently for casual day-to-day measurements, and mechanical/technical fields use either- every hardware store has both US & Metric nuts, screws, bolts; nearly every ruler has both US & Metric measurements, and so on. I won't go into the benefits of the US system here - mainly, how the units are sized to be human-relative rather than atomic-relative and how that makes them less cumbersome for everyday use - but there's clearly benefits to both systems, and we use both.
@@PeteBobGee America's customary measure has drifted significantly from Imperial. A close examination of the history of the Pint is most illustrative en.wikipedia.org/wiki/Pint
@@CapnSlipp imperial is just illogical, in the metric system you basically have a standard unit. size is m, weight is g, and so on.
we use si-prefixes (Powers of ten), instead of things like: 1foot = 12 inches.
If you want to convert from inches to foot you will be very likely less accurate compared to dm to cm for example.
I just use whatever units that I am given and treat them like variables throughout my calculations, then I do all the unit conversion crap at the very end. =P
@@CapnSlipp in metric, if a unit is not "human sized" you can just use a multiple (as it's done with g->kg) and its not true that imperial (customary) system units are in general more "human sized", for example litres fit better everyday liquid (milk, water...) needs of a human being than gallons. So the only advantage of the consumary system is that people in the US are already habituated to it. There's literally no other advantage.
I would like to thank you a lot for your effort in educating us in such an amazing way. I enjoyed every single video on your channel and I love the way you visually demonstrate all these concepts. You are able to transform something that many times scares and bores so many people into something pleasant and fullfilling. Please, keep posting so we can learn more and more!
+Henrique Feijo It's comments like this that make my day :)
Fill the 3 gallon jug (J3) and pour it into the five (J5). Then do it again. You now have 1 gallon left in J3. Empty J5 and pour the one gallon in from J3. Now fill J3 again and pour it in on top - 4 gallons! Thank you, I'm here all week.
Edit: then I watched the rest. Oh well. :)
Very very interesting !!!
1. This video
2. RUclips recommending this video after 4 years it's been posted
I survived! My solution is different from the one in this video. Fill the 3 gallon, pour it into the 5 gallon, fill the 3 gallon, pour it into the 5 gallon stopping when it is full, leaving 1 gallon in the 3 gallon, empty the 5 gallon, pour the one gallon from the 3 gallon into the 5 gallon, fill the 3 gallon, pour that into the 5 gallon, and you have four gallons in it. The solution given in the video is simpler, but I need to get the job done in 30 seconds! The best answer is *not* required. It took me 17 seconds to devise my answer so I need to really hustle filling and pouring. I have no time to look for a short sequence.When I finish watching the video I see my solution presented at 8:13, but I solved it at the beginning within 30 seconds of being presented with the problem.
i really love the representation of the problem, and how the structure solves it. kinda satisfying.
One thing you haven't mentioned is that the "rebound" of the red line isn't predetermined; once you hit the border, you can (as in reality) choose the direction among the ones available (and as you explained, every direction represent a specific action, fill or empty one of the jugs, or transfer between the jugs).
I was thinking about this because the fact that the plane is skewed seemed to be functional to the rebound, but in the end it's only an aesthetic choice - I imagine determined by the fact that the other diagonal direction (North-East) wouldn'r represent any meaningful action in a non-skewed plane.
You're right!
Damn, nice observation!
Yes, for 2 jars, there are at max 2 interesting directions. Since a rebound requires 1 incoming direction and 1 outgoing direction; the rebound is predetermined.
But for n>=3 jars, you can have n(n+1)/2) interesting directions... so there choice comes into play and you the rebound isn't predetermined.
My approach was this:
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!
I got another solution when I tried this myself :)
Fill the 3gal, poor it all into the 5gal, fill the 3gal again, poor all from the 3gal into the 5gal until the 5gal is filled, now there is 1gal left in the 3gal, empty the 5gal, poor the 1gal from the 3gal into the 5gal, fill the 3gal again and poor it all into the 5gal and you end up with the 5gal filled with 4gals :P
SmileyMPV That also works. I actually also discuss this second solution in the video. Have another close look :)
SmileyMPV This way takes longer but for me its more logical lol i mean its the first solution i came up with
how would you be sur to have on galon left in the 3 galon container? the first way Matologer shows us is tossing out the unriliable bit and fils the jug to the brim everytime
@@rubenjanssen1672
1: This comment thread is 3 years old, you are lucky to even get a reply from me (as i just watched the video today)
2: Fill the 3 gallon, poor into the 5 gallon; the 5 gal only has space for 2 gal more. fill the 3 gal again and poor into the 5 gal until full, that means you poor exactly 2 gal out of the 3 gal, so your left with exactly 1 gal in the 3 gal container. Empty the 5 gal and put the 1 gal of water in it, now that the 3 gal is empty, you can get 3 gal and add it to the 1 gal of water in the 5 gal, and you have the 4 gallons of water exactly
3: The video even talks about this and shows a visual at 8:10
That's the one I first came up with too
Now I'm prepared for the next time a villain has me opening an armed bomb and tells me weigh 4 gallons of water with 5 and 3 gallon bottles
That's great :)
The incredible feeling of satisfaction this video gave me is exactly why I love math.
After all this video is exactly what math actually is. Not numbers and algebra, but something deeper.
In the end, "Mathematics is calling different things by the same name" -Henri Poincare
For the DH25 puzzle, Simon might have provided one of the jugs with a specified amount initially. This toughens the puzzle as BW can no longer experiment. Once the initial "pre-loaded" jug has been added to or subtracted from, the initial conditions cannot be replicated. The entire puzzle must be solved in their heads (or on paper if any is available) before pouring into or from the pre-loaded jug.
By choosing a jug and initial (partial) amount, the graph can be initialized at any point on the edge. By providing an initial (partial) amount in both jugs, the graph can be started from any interior point as well.
Maybe, for example, he had 2 gal. in one (and only one)? For this to work, in gallons it would just need to be one under a multiple of 3 (because the desired volume is too and the GCF of the container sizes is 3)
In the game Rusty Lake: The Hotel, there is a mini-game in Mr Deer's room which is similar, but with three flasks: 10 dL, 5 dL, and 6 dL. And the goal is to get 8 dL. But there is the added condition that you have exactly 11 dL to work with. This means that you are working within the triangle a+b+c = 11, which turns this 3D puzzle into a 2D puzzle, and you can solve it like above.
You have to take some slices off the triangle, to account for the sizes of the flasks. Each corner of the triangle is where there would be 11 in one, and 0 in the other two. So from the Ten corner, slice off a 1by1by1 triangle, from the Five corner, slice off a 6by6by6, and from the Six corner, slice off a 5by5by5. So you're left with a pentagon with corners (10,0,1), (10,1,0), (6,5,0), (0,5,6), (5,0,6). It starts you off on the point (5,0,6). And so you can solve it in the same method as above!
(5,0,6)__________(10,0,1)
/ \
/ /(10,1,0)
/ /
/ /
/___________/
(0,5,6) (6,5,0)
Also nice. Maybe also have a look at this page www.cut-the-knot.org/ctk/Water.shtml :)
I would really be interested in the visualisation of a harder version of this problem: a 3 dimensional version (3 water containers). Obviously a lot harder, since you can choose one of two paths after hitting every edge, but that just makes it more interesting.
If you have a third jar, I think this table can work in 3 dimensions (looks like an oblique parallelepiped)
But how would the ball bouncing analogy work? At every point you'll have 2 different routes to go instead of just one.
How would you make out a 5 of container sizes 6, 8 and 15?
The analogy could still work -- you just need to imagine you're bouncing off of a 3-d space's walls, rather than a 2-d plane's walls. You can in fact have an indefinite amount of jugs, and the basic principle remains unchanged.
You'd just forget the 6-gallon container and do it with the 8 and the 15, seeing as they're coprime.
Yes, as long as you have two co-prime containers, you can ignore the rest. But if you fear it will take a long time to reach your target, then using more containers would be beneficial.
With 2 jars, there are at max 3 possible actions at any point in the process: 1) Completely fill/empty the first jar, 2) Completely fill/empty the second jar, 3) Completely transfer contents from first to second / second to first jars. That's why Mathologer uses 3 axes in his diagram, to represent the 3 different possible routes.
Each action must necessarily either completely deplete (0) the donating body or completely fill (3 or 5) the receiving body or both. Technically, we always start from (0.0); in the first solution, he moved to (5,0) and in the second solution he moved to (0,3) in his first step.
In either case, starting from the boundary, we can only move to another point on the boundary and so on. Though we always have 3 options, completely filling/emptying one of the jars would move us to a corner point; which can easily be reached without this complication. So there's actually only 2 interesting directions.
By constructing the axes to be 60 deg to each other, he can compare the trajectory of a solution to the bouncing of a billiard ball off walls.
With n jars, you'll have at max (n+nC2) routes. So moving from boundary point to boundary point (meaning at least one the jars is either completely empty of completely filled), you can have at max all these n(n+1)/2 routes as interesting when n>=3.
For 3 jars, that means 6 interesting directions from a point. Mathologer was able to use the bouncing analogy for 2 jars since there were at max 2 interesting directions; and bouncing requires 1 incoming direction, 1 outgoing direction, and 0 other interesting directions.
You can still use the bouncing algorithm for higher dimensional space; but a single run wouldn't be able to yield the complete solution space. Because for at least one of the points in the trajectory, you'll have multiple directions in which to bounce off.
@Mathologer - you NEED to make an extension of this to explain graph search.
I'm a computer science engineer and this can be generalized to a graph search problem and we can use different types of graph search traversals (like BFS/DFS/A* search) to get to a solution from any state to any other state in the most minimal number of moves. The same can be extended to solving Rubik's cube and so on. With A*, you need to create a mathematical heuristic which helps you get to the answer faster.
I could barely even understand the problem when I first saw this movie as a little kid, and I left the movie still not getting what had happened. Flash forward to my present day 17 year old self, and I figured it out in the 30 seconds allotted. Decade younger me would be proud.
Robert Cohn what kind of seven year old is watching die hard 2?
A cool one
Mitch Harris I don't know, but this was Die Hard 3.
The German accent makes you the villain...
We love Germans, honestly...
especially hitler ❤️❤️
@@youcantspellslaughterwitho4353 Hitler was Austrian.
@@angrytedtalks austria wasnt a thing
@@youcantspellslaughterwitho4353 Germany was founded in 1871. Austria was left over from the part of Bavaria Germany didn't get.
There have been 5 famous Austrians: Mozart, Straus, Freud, Swartzenegger and Hitler.
@@angrytedtalks I'd probably add Hundertwasser to the list. And Haydn. Schrödinger. Wittgenstein … Niki Lauda is also quite well-known. And think about royalty … Marie Antoinette was Austrian. But I have to admit they might not be the first one thinks about. Theyʼre famous people, though.
You can fill the small one, pour it into the big one twice until you have 1 gal left, empty the big one, and pour the 1 gal and a 3 gal into it.
This method is so simple and amazing! I love that your channel is full of interesting stuff like this and you explain things very clearly. So glad to have discovered another great math channel. :)
Jing F Glad you like our videos and thank you very much for saying so.
I paused and had some found another solution :) (don't know if it's in the rest of the video yet)
Fill the 3 gallon completely.
Empty it into the 5 gallon.
Fill the 3 gallon again.
Pour all of the available water into the 5 gallon. The 5 gallon only has space for 2 gallons so there will be 1 gallon remaining in the 3.
Pour all of the 5 gallon out into the fountain.
Pour the 1 gallon from the 3 gallon container into the 5 gallon.
Fill the 3 gallon again.
Pour the remaining into the 5 gallon. Problem solved!
Great minds think alike: I came up with the same procedure....
In general, you can only achieve volumes that can be expressed by mA + nB, where m and n are integers and A and B are the capacity of the containers.
In the first case, A = 5 and B = 3, so since you can express 4 as 2*5 - 2*3 (or 3*3 - 1*5), this means that 4 gallons is achievable. 7 gallons is also achievable, since 7 = 2*5 - 1*3 or 4*3 - 1*5.
In the second case, A = 15 and B = 6, thus the expression is m*15 + n*6, Since m*15 + n*6 = 3*(m*5 + n*2), no matter what we have inside the parenthesis, the result will always be a multiple of 3. So, we can achieve only multiples of 3 (gallons).
Congratulations for your videos. You got a new inscription (from Brazil).
+Paulo Bouhid Glad you like our videos and thank you for saying so. You are absolutely right! I once wrote up a little bit of an analysis of what is and what is not possible with the billiards ball method along the lines you are suggesting (for a fun maths course that I am teaching at Monash uni). If you are interested I put it here for you: www.qedcat.com/billiards1.pdf
+Mathologer I thank you... we all learn something new with your videos, even about subjects we already know. Ans tk you for the link... I´ll take a look. Greetings from Brazil.
All under control then. Greetings from Melbourne :)
I started watching your first Simpsons math video yesterday evening and now I'm here and somehow it's a new day and already getting dark again outside... :-o
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 :D riddles!
:)
You can approach 5 from a 6x3:
Empty x & y. Fill x to 6. Fill y ~1/3 full from x so x~5 & label the levels x="5?" & y="1?". Empty y. Fill y to 3 from x so x~2 & label the level "2?". Empty x into y, refill x to "2?", empty y into x & label the doubled level "2*2?".
Fill y to "1?". Empty y into x so x~1. Fill y to 3. Empty y into x so x~4. If below "2*2?", "5?">5. If above "2*2?", "5?"
This is awesome. i've always loved that scene for the puzzle aspect. This is an awesome video!
Could you use this method 3-dimensionally for more than two containers?
Steven Boliek I replied to a similar question a couple of weeks ago. Should be easy to find :)
I think, just off the top of my head, if you create your 3 dimensional shape and start at 0,0,0 and choose which direction to start, which equates to filling one of the jugs, that would be a 1 in 3 choice to start. Then I think at every 'bounce' you would have to choose which direction you want to bounce, which equates to which 2 jugs you want to interact with.
So it would be a lot more complicated to find a solution.
And yes I know this is a 5 year old post.
The Die Hard version is a pretty easy version of the jug puzzle. (Three jugs would probably be harder?) In fact, there's two easy ways to do it. One method would be to fill the 3g, pour it into the 5g, re-fill the 3g, pour all you can into the 5g, empty the 5g, pour the remaining water from the 3g into the 5g, re-fill the 3g, and pour the 3g into the 5g. The other way (which is a few steps shorter and also more intuitive in my opinion) is to fill the 5g, pour all you can into the 3g, empty the 3g, pour the rest of the 5g into the 3g, re-fill the 5g, and pour all you can into the 3g. Either way leaves you with 4g in the 5g jug.
he showed both in the vid so gg for answering before the vid
Understanding your solution was easy, actually figuring out how you came to that solution is leaving me stumped.
I tried to solve this and I found one more possible sulution :
1) fill the 3 jug
2) pour the 3 gallons to the 5 jug
3) fill the 3 jug again
4) pour as much from 3 jug to 5 jug (there will be 1 gallon left in 3 jug)
5) empty the 5 jug
6) pour the 1 gallon to the 5 jug
7) fill the 3 jug again
8) pour the 3 gallons from the 3 jug to 5 jug (And now you have 4 gallons in 5 jug)
Or just buy 4 gallons jug :D
Never thought I’d see Mathologer do a Christmas episode… and to think they already had one, many years before I’d even heard their name!
Alternatively, you could pour a full three gallon into the five, then refill the three and pour into the five until you just fill the five to max. Now you have exactly one gallon in the small jug. Completely dump the five to fully empty and then pour in the one gallon from the small jug into the five. Then pour a full three into the five and you have four gallons.
There's more than one way to get the answer, but if a timer on a bomb is ticking down... who knows how well one could concentrate if this were to actually happen.
This could actually sort of work as a real-life game.
I see a lot of potential there.
Let a and b with a>b be the sizes of the jugs. When you pour water between them the total water quantity changes by one of +a, +b, -a, -b so the water quantity changes by +b or -b mod a. That means the quantities that can be obtained in the jug a are the elements of the subgroup generated by b in (Z_a, +), that is, all the multiples of gcd(a,b) ( mod a )
These two-jug problems can look difficult, but they are almost impossible *not* to solve. Fill either one, then keep doing the only thing you can do that isn't backtracking until you're done.
It's modular division.
I guess I'm the only one who would notice things like the difference in the weight of the two containers would be more than an ounce, so if a variation of one ounce causes the bomb to go off, there's a chance you're getting blown up even if you manage to get the 2 gallons exactly (depending on which container he used when accounting for the weight. More importantly, mass production containers (which those clearly are), will never be "exactly 3 gallons" and "exactly 5 gallons". If you get a 3 gallon container, it is 3 gallons plus a certain amount of extra air space (and in this situation, you don't know that amount). For this to be in any way practical, you'd need bespoke containers, or at least have drawn on lines showing the fill levels (in which case you're going to run out of time trying to get them filled exactly to that point). So yeah, no matter what, short of blind luck, you're getting blown up.
wow this is really the best explaination I found online, thank you!
For the entire video I was wondering if there is a combination of water tanks for which some solutions are impossible. It's great that you tackled this question at the end of the video as well ;)
I prefer starting with the 3 gallon jug - filling it up and emptying it in the 5 gallon jug. Do that again so the 5 gallon jug is full leaving 1 gallon in the 3 gallon jug. Empty the 5 gallon jug and then put the 1 gallon from the 3 jug into the empty 5 gallon jug. refill the 3 gallon and put it into the 1 gallon in the 5 gallon jug and you have 4 gallons.
From the thumbnail, I thought Bruce Willis was goona giva a math class
I have a different solution for the water problem (before watching the diagram explanation):
- Fill 3 gallon container
- Pour it over into the 5 gallon container
- Repeat, which will leave 1 gallon in the 3 gallon container
- Empty 5g container and empty 1g from the 3g container into 5g container
- Fill 3g container and pour it into the 5g container, which will result in 4g as well
Proof that you can always obtain any number divisible by gcd(A,B):
Suppose A > B. Then filling up the A bucket and repeatedly transferring to the B bucket and dumping corresponds to repeatedly subtracting B from A, so we end up with R
The state machine like approach is quite interesting... I also looked your hidden cube in simpsons video which also has a state machine approach. Really nice videos :)
I worked out the second way, fill the 5l jug twice leaving 1l in the 3l jug. For the 15l jug you could poke a hole and time how long it takes to empty. Then calculate how long it would take for the relevant amount to drain, leaving the required amount. Given that you only have 30 seconds, perhaps you could cut the whole bottom off.
I've binge watched about half of your videos now and this one is my absolute favourite so far (which says a lot since all of them are amazing). I'd love it if you made another video about the "table" where you go more in depth into it. Maybe there are ones with different shapes that work with more than two bottles? Hexagons?
Great, glad you like this one so much :) I've been thinking about building a physical table whose sides are made from mirrors and such that two of these mirror (up and right) can be moved to make tables of different sizes. Then replacing the billiards ball by a laser beam would make for a nice analog computer for calculating the gcd of two integers.
Wow that is a GREAT IDEA, do it!!!!!!!!!!!! Please.
Mathologer Wow, you might not believe me but I had the same idea while watching the video. You just have to cover the piece of mirror with the desired result and you have your route. You might also need some smoke. Looking forward to this.
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.
This is my solution after watching the scene and in my opinion it was a breeze. Fill the 5 gallon jug then pour from the 5 gallon jug into the 3 gallon jug until the 3 gallon jug is full. Empty the 3 gallon jug and then pour the remaining 2 gallons from the 5 gallon jug into the 3 gallon jug. Lastly fill the 5 gallon jug up once more and pour from it into the 3 gallon jug until the three gallon jug is full. Since the 3 gallon jug already contained 2 gallons at this point you will have poured over 1 gallon of water and the 5 gallon jug will contain 4 gallons of water.
Edit: I see that you solved it in the same way :D
3:18 grid run
9:13 proof
13:13 formula
Fun fact: if the side length of a square = n, the area of the square = (n^2)(cm^2); same for cubes but it’s (n^3)(cm^3).
You may also think of this as a regular Cartesian coordinate grid with the diagonals being lines of the form x + y = n where n is an integer. So (x,y) are your amounts in the jugs and since you can only start with one jug full, the solutions must always be integers. n is how much water you have total. The verticals and horizontals are just the actions of entirely filling an empty jug or emptying a jug that is already full.
Yep, that works, too :)
You can only touch each node if both numbers are prime. When you add or subtract them, you get remainders that aren't shared factors or divisible numbers.
Any other combinations of non prime will lead to paradox
I think the numbers just have to be relatively prime not necessarily prime numbers.
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.
Excellent work man!!! I like the way you bring mathematical problems on the table.... 1000👍
for 1 gallon you could fill the 3 and poor it into the 5, then do that again and you will have 1 gallon left for the scales. for 2 you just fill the five and poor into the 3
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.
In the case of any quantity of liquid that is less than or equal to 3, the choice of which container you will use becomes relevant. With greater than 3 gallons and less than or equal to 5 gallons it is implied that you must use the larger container, and thus you would expect the weight of the container itself + that many gallons would be what the scale is tuned to measure. With less, using the wrong container would lead to your death because weight of the containers themselves also contributes to the weight. If it is tuned to weigh, for example, 2 gallons in the smaller container but you used 2 gallons in the larger container, boom. If it is tuned to 2 gallons in the larger container and you used 2 gallons in the smaller container, boom. There is only a clear choice for the higher range of values, unless you pretend that the containers weigh less than an ounce, as that's the tolerance that was communicated. Per google, an empty 5 gallon jug weighs about 12oz and a 3 gallon weighs about 8oz. Oddly, in the clip he also states to put the 4 gallons in "one of the containers" implying either one would work. That would only make sense if there were two different valid ranges of weights that would be accepted by the scale.
The area actually stays the same, well worth doing the math :)
One more observation that I'm not sure was covered in the video or the comments. This puzzle is solvable for 4 gallons because 3 and 5 are relatively prime. And so n*3 modulo 5 will eventually produce every gallon increment from 0 to 5 for some n ranging from 0 to 4. Knowing this, we also are able to deduce, among many possibilities, that we could produce every gallon increment with a 15 gallon container coupled with a {1, 2, 4, 7, 8, 11, 13, and 14} gallon container, or even beyond this such as {16, 17, 19, 22, 23, 26, 28, ...} because these numbers share no common prime factors with 15.
Nevermind. After a deeper search, I notice a few people over the years have made similar observations already, and have had them confirmed by Mathologer. Great video!
Solved that in ten seconds by filling the 5 gallon jug with 2x 3 gallon jugs and then emptying the 5 gallon jug, leaving you with 1 gallon in the 3 gallon jug. Then empty the 1 gallon into the 5 gallon jug and adding another 3 gallons from the 3 gallon jugs. Solved.
yeh that's how I Worked it out. This way is far more intuitive and simpler than the one shown in the video
This has to be my favorite maths problem in Hollywood. Subscribed :D
Let's have an urn with 3,5, and 8 different colour marbles. Let's draw 8 marbles from the urn. The cases of the distribution we get are isomorphic to the states on the first billiard table. The last parameter can be greater than 8, it's water in the tap. When we empty a jug we're putting water back into the "tap". Also, this shows how to generalize the problem and solve ones with more than two jugs.
axxization Yes, absolutely all this generalizes nicely in a couple of different ways: replace the tap by a third jug fully or partly filled with water, add more jugs, and so on. And for some of these generalizations what I talk in the video can be adapted. If you are interested in finding out more google "decanting problems".
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.
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.
@2:15 "I think anybody who actually thinks about this a little bit will come up with this solution"
I thought first of another solution where mostly the 3-gal jug is moved (which is easier):
Fill 3-gal jug and pour all the water into 5-gal jug.
Fill 3-gal jug again and pour water into 5-gal jug until full. Then 1 gallon is left in 3-gal jug.
Pour out 5-gal jug (only one move with this jug) and fill the 1 gallon into 5-gal jug.
Fill 3-gal jug and pour all the water into 5-gal. Now, there are 4 gallons in the 5-gal jug.
The second solution @8:10 is well visible in the diagram. Well done.
At the end, it seems like we can prepare any volume in full gallons if and only of the two volumes in gallons do NOT share a common divisor larger than 1. If they share a divisor larger than 1, like 2 or 3, then we can make prepare only volumes of multiple of that common divisor in gallons. Nice diagram.
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?
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.
I gotta say, this would be more intuitive if you used a rectilinear system. The box would be 5 by 3, with diagonals running down at a -1 slope. Then a vertical or horizontal line represent filling or emptying one of the bottles, while a diagonal means transferring from one bottle into the other (hence the total amount of water, x + y, remains constant). At each intersection you can choose to travel horizontally, vertically, or along a downward diagonal but you cannot stop until you reach the edge of a box, meaning one bottle is completely full or completely empty.
I worked it as fill the 3, pour into the 5, 2 space left in 5, refill the 3, pour into 5, 1 left in 3, empty 5, put 1 from 3 to 5, refill 3, pour into 5
just got further into the video lol nvm
Given N jugs, is there an analogous N-dimensional graph that tells you the solution(s) or does that introduce a >1 branching factor making it a harder problem?
After 12:30 ... Okay, I would pay ANY ticket price to see John McLean match wits with an evil, twisted genius with a German accent played by the Mathologer! Let's make it happen!
It may be more steps, but i thought of a different way before watching the rest of the video. Fill the 3 gallon, then dump it into the 5. Fill the 3 again and dump it into the 5 leaving the 1 gallon left over. Dump the 5, then put the 1 gallon into the 5 gallon container. Then fill the 3 gallon and add it to the 1.
If you keep on watching I also mention your solution :)
Mathologer I realized that after commenting. mistakes were made xD
Sure, no problem :)
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.
Me too! But he goes through this solution when he walks us through that diagram.
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.
Turn each bucket on a 45 degree angle. Fill both containers until the water level forms a diagonal. The container will be exactly half full. 1/2(5 +3) = 4
+Rosa Lyn Good idea. Probably won't work with the containers that they are dealing with in the movie though. For your trick to work you would need cylindrical containers :)
Haha awesome guy, so German! First video of this channel I saw, and will subscribe
1:40 fill 5 gallon(leaving 2 gallons) pour into 3 gallon. DISCARD 3 gallons.
pour remaining from 5 gal into 3 gallon refil 5 gallon.
finish filling 3 gallons (currently holds 2 gallons, 2+1=3) with 5 gallon jug.
5 gallon jug now contains 4 gallons 5-1=4
thanks, i was always thinking how they've done it cause i came up with a different solution that works as well.
fill 3 gallon bottle and pour all in 5 gallon bottle. then again fill 3 gallon bottle and fill the rest of the 5 gallon from the 3 gallon bottle. then you will have 1 gallon remaining in the 3 gallon bottle. pour the 5 gallon bottle out and fill that remaining 1 gallon in the empty 5 gallon bottle. the fill the 3 gallon bottle and pour all in the 5 gallon bottle. and then you have it. :-)
There are multiple solutions...
Thx for the explanation. What's the name of the "billard-table"-thing in terms of math? Never seen it, but looks interesting.
By the way, Simon dies. He's in a helicopter with his girlfriend and McClane shoots out the power line above it causing it to tangle into the rotor and making the helicopter crash into a fireball.