# How not to Die Hard with Math

well a mathematician and I like action movies particularly die hard is one of my favorite you know action movie and as a one which has a couple of Matt's problems and one very famous one is in this clip so just play the clip and then

We talk about a little bit careful don't open it what I gotta open and it's gonna be alright I told you not to open it I tried to see the message it has a proximity circuit so please don't rock yeah I got it we're

Not gonna run how we turn this thing off on the faulty there should be two jobs do you see them a 5 gallon and a 3 gallon fill one of the jugs with exactly four gallons of water and place it onto scale and the timer will stop must be

Precise one answer more or less will result in termination if you're still alive wait wait a sec I don't get it you get it no it's a problem 30 seconds I mean I'm pretty good at these things but I don't know if this was the first time

That somebody paused this problem 30 seconds I don't know anyway so let's just have it really really close look what's going on here we've got two containers a five gallon container and a three gallon container and now Simon the

Villain tells us to make exactly four gallons of water just by chopping things back and forth between those two containers Oh No 30 seconds well we probably dead but anyway let's just think about it and see whether we can

Figure out what's going on there all right so here's a solution okay here's a solution and I think anybody who actually thinks about this a little bit will come up with the solution okay so what we do is we fill up the five gallon

Container then we pour as much as possible from the five gallon into the three gallon container so it leaves us with two gallons in the five and fills up the other one completely okay we've got two and three there okay what comes

Next well the next thing we do is we just get rid of those three then we fill the two into the empty one like that then we fill up the five gallon container like this and then we pour as much as possible from the five into this

One here well there's only one one gallon dirt fits in here so that gets us to four on that side finished put it on and well probably ten minutes by now but you know we're in heaven we're still putting it

On all right now I've got a really really really cute mathematical way of solving this problem and lots of related problems and I just want to tell you about that one okay it goes and actually goes with billiards mathematical

Billiards it's a special sort of billiards table well if you have a look at it it's not rectangular like the billets table you find it pop it's it's kind of skew right so there's a 60 degree angle here all right and well

What are we going to do well first of all have a look at the dimension of this table dimensions kind of a giveaway you know there's three units kind of this way and there's five units going this way so it must have something to do with

The volumes of the containers all right then what we're going to do is we're going to put billets ball in one of the corners and then we shoot it at 60 degrees and just see what it does okay and well let's see what it does right so

I'll shoot it it bounces here and it's reflected off at 60 degrees and it bounces there it goes like that and over here and there and that's actually our solution how is it our solution well it's maybe not a parent yet was probably

Not a parent yet so let's let's put in something else so what we think of here is is if you think of this this year and that one here as like axes of a coordinate system like XY okay so if this is X and this is y then there's the

Origin you know zero zero then we go over one this is gets us to the point 1 0 then over to point 2 0 and so on and up here is 0 3 and they're up in the corners well 5 over and 3 up which is 5 3 ok ok so let's let's shoot our Biltz

Ball again okay so we put it there and right at the moment it says 5 0 and basically what it tells us is 2 fill this container all the way up so we do that then we should fill its ball like that and then we'll just read off

The coordinates here two three which tells us that we should pour water from here to there as much as possible because there we go all right now it gets reflected off down to there so we're now a 2-0 which tells us we should

Get rid of the water in the three gallon containers we get rid of that then follow it further zero 2 that means we're pouring the water from left to right and then we go over here which just means we're filling the

5-gallon up all the way up and then one more step and that tells us well pour some water from the five-gallon into the other one and that leaves us with four three it's exactly the solution that we came up with at the beginning so pretty

Neat okay well what if Simon had asked us to put one gallon of water on the scales well then that method he actually tells us what to do because what we do is we just kind of keep on going in keep on going so it'd be the ball kind of

Keeps on bouncing here and let's just go all the way and you can actually see it goes across all the lines that I had here originally okay and well now if you have a really close look you can actually see that in this position here

That corresponds to one gallon being in here and nothing being in there so you just take this this container for little scales and you're okay now this one here corresponds to two gallons so it could also have done two gallons if you had

Said two gallons no problem this one here says well well three gallons pretty obvious you can just fill up that one and put it on so it would be a really easy puzzle so I mean Simon's meaner than that four gallons we can also do

We've just done that five gallons easy but there's more you can also see at this point in time there was five gallons in here and one in there so we could actually take both containers put them on a scale and that would be six

Gallons of water right and in this position here we have five gallons in here and two gallons in here so that would give us seven gallons we could put that one on solve another puzzle and we could also do five plus

Three of course age so all the numbers from one to eight we can actually do as this diagram shows us okay there's more in here I was wondering actually then isn't there a faster way to get to one as soon

As we touch by one or one three without having to complete the graph yeah like so as soon as as soon as you touch as soon as you touch anyone you're done okay good any any one you're done that's fine yeah so there was my my friend

Colleague and cameraman Giuseppe who just had the right thing to say all right now next thing is there's lots more hiding in this diagram and then you would imagine okay so there's a second solution here

And the second solution well how does this come about well you could actually start from here and start from there why'd you just shoot the ball from there and then what happens well let's see zero three corresponds to filling that

One up first remember before we filled that one up and then what kind of the water was kind of flowing in this direction you kind of always fill this one up and pour over there until it's full and then you kind of get rid of

Stuff right and now kind of the waters flowing in the opposite direction okay okay now we shoot the balance ball down there tells us transfer the water alright now we shoot it up there tells us fill that one up water is flowing

From here huh okay next one five one so we pour as much as possible over here gets us to five one okay then what are we supposed to do now just get rid of that one no then transfer the one then fill up the three then you know just

Pour it in and you've got the other four that's the second solution it's a bit longer than the first one but also works pretty neat right okay what else is there well I should really tell you why this works all right yeah I'm the

Mythology I'm not really happy about all this stuff until I've got a really really good explanation for these things okay so how do we go explain this well basically the method works because the individual bits that the power

As made of work what I mean by this let's have a look at one of those connections here what does that connection actually stand for well it stands for one of the drugs being completely empty the five one and the

Other one has something in it and then what this connection stands for is just filling that guy which is empty all the way up and if you go the other way which might also happen it just means you just emptied a

Completely full 5-gallon jug you know that's it right and obviously if you're in a in a state like this if you in state zero one you can go this way and if you in state five one you can go there so this connection here stands for

Something that really works in reality okay that is the second kind of connection here and that's this one here it's exactly the same sort of thing instead of filling an empty five or empty a full five you're now filling an

Empty three or emptying a full three okay so exactly the same thing this sort of connection here corresponds to something that really works in reality okay I've got a third kind of connection it goes this way well as if this

Actually will become more complicated here the situation because well you can have a connection like that you can also have something like this and it can be done there and there so you know what what's going on here

Well for this one here to really see what's what's going on it's actually helpful to kind of go in little segments here so let's start from here and just go to this point here okay that's actually three one okay so it's three

Over one over so what what are we actually doing when we're kind of moving along this this segment well we are kind of pouring water out from the from the big one from the five gallon one and we're filling it into the other one

Right so here we star was four zero we're going one down and one up total amount of water stays the same right and so we're moving in this direction we're basically pouring water from here to there one segment here corresponds to

One one busy gallon making a transfer and you hit the other side well you got exactly the right amount you can basically hitting this boundary so it's going to work all right so it's going to

Work this sort of transfer again corresponds to something that you know happens in reality so these these two points when you actually connect them you know that that really works now a past ability the path of the bullet

Spore it's just made up from these individual segments that work right so if we start out with something that we can actually achieve like a 5 0 then all the other bits are connected by a things that works or the whole thing has to

Work so we automatically do the right thing nothing can go wrong ok what else well at some point in time there's going to be die ha 25 and actually actually pride myself that I'm a little bit it looked quite similar to

Bruce villains so I'm going to see whether I can be Bruce Willis in die hard 25 and then solve the problem with my method here so but I died 25 there's also going to be a diet Simon's going to be back as out of prison by now and I

Don't know actually why they died he probably died right I can check it you can check it do you check it ok so just epic is gonna check it while I'm he's gonna check it on his iPhone while I keep talking anyway so let's say Simon's

Back either from prison or from the dead and he's going to tell me well this time I'm going to make it harder for you I'm going to have a 6 gallon jug and a 15 gallon jug and what I want you to make is a 5 gallons of water ok and I'm going

To you know see whether my method actually works right so what I'm going to do is I'm going to make up a billiards table and has dimensions 15 and 6 and then I'm going to just run my ball again and I know well fingers

Crossed and see what happens when I run my ball and actually I mean there's a bit of a problem here because the Biltz ball actually doesn't hit every single one of the points down here so it doesn't hit any one of the doesn't hit

The one doesn't hit the two it hits the three not two four and up to five hits the six and in fact all the coordinates that you come across here are multiples of three and that's sort of true in general so if you've got

You know volumes here and there then what you can do is you buy what you have to do is you basically take the greatest common divisor of the two numbers which in this case is three and then all the volumes you can make up are just

Multiples of of the greatest common divisor well in this case we're actually out of lucky he said I was supposed to do a five account to a five there's no you know there's no five anywhere in here that that's going to work so I

Actually have to think of something else I probably dead 30 seconds I won't be able to think of anything else