If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Alien abduction brain teaser

Saving Earth from becoming a mushroom farm. Created by Sal Khan.

Want to join the conversation?

Video transcript

Ten of us have been abducted by aliens because they view us as being representative of the human race. And what they're going to do is they're going to test us to see if the human race is worthy of joining the intergalactic council of planets. And if we're not, they're going to kill us all and and turn Earth into a mushroom farm, because that's their oil. So they take us together in their spaceship and they say, you ten represent all of humanity, and the fate of humanity rests in your hands. And we'll give you a test. And the test is tomorrow. 24 hours from right now, we're going to put you all in a completely dark room, and line you all up one behind the other. So if this is one guy-- let me see if I can draw-- so if this is the guy in the front. He's looking a little worried. Someone described me as the Bob Ross of mathematics. So I'll attempt to do a little Bob Ross work right here. So this would be the first of us. He has a business tie on, and whatever. He's facing in this direction. And then there's ten more of them. So instead of redrawing them, let me just copy and paste it. We all look mysteriously similar to each other. That's the second one. And the third one. There's ten of us like this. I'll do one more. Oh that's good enough. There's ten of us, and we're essentially lined up front to back, so that this guy, all he sees is the back of this guy's head. And he can also see the back of this guy's head. Maybe there's a slight incline, maybe the floor is like this. Let me see if I can draw it. The floor is at a slight tilt, so one guy is standing right here. Another guy is standing right here. Another guy's standing right here. There's ten of us in a line. We're all facing in that direction. All this guy right here can see is the wall. This guy can see the two guys in front of him. This guy can see the one guy in front of him. There's ten of them. It goes all the way back to ten So what they tell us is we're going to line you up like this. They even draw a nice diagram like this, because they want to give us a fair chance of preventing Earth from turning into a mushroom farm. And they say, while the room is completely pitch dark, we're going to place a hat on each of your heads. And the hat will either be mauve-- so this would be a mauve hat. Or they'll be green. So they either get a mauve or a green hat on the back of your head. And the hat will be designed in such a way, it won't have a big rim. So that you can't look up and see your hat. This is alien technology, so it is completely impossible to see the hat on your own head. And the distribution of the hats will be random. It could be all green hats. It could be all-- well, I'll say purple-- because I'm not quite sure how to pronounce mauve. So it could be all purple hats, it could be half purple, half green. It could be nine green and one purple. They don't know. It could be any combination of hats. And what they're going to do-- and they tell us all of this-- is that they're going to start with the person in the back. So this is the front wall, this is the floor. This is the first guy right here, second guy, third guy, fourth guy, fifth guy, sixth guy, seven, eight, nine. So there's the tenth guy. They're all faced in that direction. They're going to start with this guy right here. And say, what color is the hat on your head? And he'll answer, either purple or green. He can only say purple or green. I have to be exact here. He can only say purple or green. And he can say it as loud as he wants. But he has to say it at an even tone, so that not more information can be conveyed, other than the fact that he thinks his hat is purple or green. Although this guy is close enough that he can hear it. Everyone's going to hear what everyone's going to say. But there's no intonation. And if you're right, if you say, my hat is purple and you are wearing a purple hat, you will live. And the 600 million people that you represent will also live. And where they live will not be turned into a mushroom farm. And if you're wrong, then they will immediately-- what is that Star Trek weapon? Displace you. And they'll also do it to all the people you represent. And turn all of their land into mushroom farms. So there's this huge incentive to try to get this right. So they say, we're going to do this tomorrow. And your goal, obviously, is to try to save as many lives as you can. And so we're going to put you in a room, and you guys can discuss this for the next 24 hours, to come up with a system so that when we put you in the dark room and we put the hats on each of your heads. I shouldn't be drawing brown hats. We'll put the hats on your head. And then turn on the lights. I forgot to tell you that. They're going to put us in a dark room, you can't see anything, we're all lined up. Then they're going to turn on the lights. And so then they'll ask this guy, what color is the hat on your head? He obviously can't look at his own head, but he'll see everyone else's hats. And likewise this guy, he can't see his own hat, and he can't see the guy behind him. But he'll hear what this guy says, and he can see all of the hats in front of him. So they'll turn on the lights, and then after this guy-- if he's right he lives, if he's wrong he'll be displaced. And then they'll go to the next guy. And then ask him. If he's right he lives, and all the people he represents lives. If he's wrong he also will get displaced. And they'll keep going all the way up to the first guy. So our goal to essentially save civilization, or at least human civilization, is to come up with a system to save as many of us as possible. So that's the first take of the brain teaser. So if you want to kind of pause it right here. And actually before you pause it, let me just clarify. All you can say is either purple or green. No intonations. You can't say "pur-puuul" or "purp-l" to kind of convey any type of information. All you can say is purple or green. Or pronounce it in some weird way. And there's no weird trick where you can kind of look with the side of your eyes or anything like this. You have to do it completely based on what you hear and what you say. And if the aliens catch any hint of you guys trying to cheat. Or all of us. I'm one of us. To cheat this, they'll just evaporate everything and turn everything into mushroom farms. So that's the problem statement. How do you save as many people as possible? And if you want to pause now, feel free to do so. And now I'll give you kind of a small hint, because this doesn't help you. It's easy to think of a lot of solutions that might save a couple of people. But there's actually a solution that will guarantee saving nine people. So that's the solution that you have to come up with. And for the rest of this video I'm just going to keep giving hints, and then eventually give you the solution. So the goal is actually really to save nine people. And you can which nine people it's going to be. And so once again, pause it if you don't want any more hints. It's going to be these nine people. These nine people are guaranteed to be saved. And this guy obviously is just going to be guessing. He is the first guy to be asked what color his hat is. He has no information. He can see the people in front of him, but he has absolutely no information as to what color this hat is. So he just guesses. So there's a 50% chance that he's right. Without any other information, we assume that there's a 50-50 chance that the hat on the top of your head is a purple or a green one. So your expected number of people you're going to save is nine and a half. With the system. So these people are guaranteed to be saved. And so, there's a couple of things that are more probabilistic that don't quite get you there. That might come to mind immediately. And once again, stop this video. Because it's fun to think of these yourself. But this guy might just see, OK how many green hats are there, and how many purple hats are there? And then whichever there are more of, he might say, oh my hat is-- let's say there's six purple and three green in front of him-- he might say my hat is purple. And he's either right or wrong, and he might get displaced. But at least he'll have conveyed that information to the rest of the group. That hey, the majority of the hats are purple, so you're better off guessing purple than green, and it'll save at least six of these people because they'll all guess purple. And that's OK, and in this situation you're guaranteed to save more than half of these nine people, so you're guaranteed to save at least five of these nine people. And then probablistically maybe you can get up to seven or eight. Then there's the other method. Well, there's a ton of them. I don't go into them because I realize I don't have a lot of time. So here is the real deal solution. So really pause it and wait and watch it tomorrow, unless you don't want the solution. The guy in the back, what he does. So there are a bunch of people. One, two, three, four, five, six, seven, eight, nine, ten people. And they're all wearing hats. And remember, we have 24 hours to come up with a system. So everyone has the system. And we don't know who's going to be in what order also. That's the other thing. But that actually doesn't help or hurt you much anyway. So the guy in the back, what he does is he counts the number of green or purple hats. Right? This is the system we've come up with. And so this is true of whoever's in the back. Whoever's in the back has to do this, right? So if he counts that the number of green-- let's say this is our system. He counts the green actually only. So count the green. And he determines that the number of green is an odd number. If he determines that the number of green that he sees in front of him is an odd number, then he is going to say green. For the guess on the top of his head. If the number of green is an even number, he's going to say purple. And of course, he doesn't know what his hat color is, but at least, well, one, he has a 50-50 chance of saving himself. But now, what happens? Now, by giving this information to the rest of the group, by screaming green or purple. If this guy screams, my hat is green! Then this guy, who's the next guy in line, the next guy to be quizzed, knows that the person behind him saw an odd number of green hats. Now this is interesting. If he counts the number of green in front of him, and he also sees an odd number of green hats, then that means that he was not one of the green hats that this guy saw. So he must be a purple hat. So he'll just say, I have a purple hat. And he will live. Right? And then you'll go to this guy. And let's go the other situation. Let's say that this guy, he screamed green. Which means that he saw an odd number of green hats in front of him. If this guy counts the green hats of the eight people in front of him, and he says wow, there's only an even number of green hats, he could say, wow I must have a green hat. And so then he'll say green. And then he'll be right. Likewise, this guy-- let's say it's the first situation that I said, this guy has a purple hat on. So this guy saw an odd number of green hats. He screamed green. And so this guy, he also sees an odd number of green hats, because he's not one of the green hats. So he says purple, he lives. This guy all of a sudden, because this guy said purple. And he lived. I mean, you didn't hear any buzzer. Actually you know he's going to live, because the system will work. He knows that there must be an odd number of green hats from him down forward, right? Because this guy didn't say green. So if he knows that there's an odd number of green hats from him down forward, and if he sees an even number of green hats, he knows that he must be one of the green hats, so he'll say green. And in that situation, if this guy screamed green then that means that if this guy saw an odd number of green hats from here on down, and one of these guys behind him, or every time someone behind you says green after that, then the number of green hats that are odd or even in front of that person will change. And so they have to keep track of that in their minds to figure out if the hats in front of them are going to be green or purple. Actually let me give an example because that's probably the easiest way. So there's one, two-- Actually let me just do it in a neutral color so I don't waste time. So let's say the hats are green, purple, purple, green, green, purple, green, green. How many is that? One, two, three, four, five, six, seven, eight, nine, ten. So you go to the first guy right here. And so he counts. He says, OK, how many greens are there? There's one, two, three, four, five. There are five greens. So the greens are odd. Which says that he is going to say green. That's the system we've come up with. So when they go up to this guy, he says green. And he's wrong. So he actually gets eliminated. And maybe the aliens were willing to give us a pass on the first guy, but let's say he gets eliminated. But he said green, so then this guy on down knows that in front of that guy there was an odd number of green hats. Now, this guy, he looks forward and he counts one, two, three, four, five green hats. So he also sees an odd number of green hats, so he knows that he must not have a green hat, because if he had a green hat, then it would turn the number of green hats that he saw into even. So he doesn't have a green hat. He says, I have a purple hat. And he lives. Now this guy, he counts the number of green hats in front of him. One, two, three, four green hats. He says, well gee, I only see an even number of green hats. Up until this guy, he saw an odd number of green hats. I must be a green hat. So he says green. Check. Now this guy's turn. So first of all, he knows how many green hats this guy saw. He knows that this guy saw exactly four green hats. Because if this guy had seen five green hats, he would have said purple. So this guy knows that this guy saw four green hats. But he sees only one, two, three green hats. Right? So he knows that he must be one of the green hats. So he screams green. So check. So then this guy knows, wow there must be only three green hats from him on down. Because this guy must have seen three green hats. If he saw four, he would have said purple. So that guy uses that same logic to say OK, there must be three green hats from me on down. I see three green hats, so I must not have one of them. I must be purple. And you just keep on going down all the way until everyone answers correctly. And you save at least nine people. And the bulk of humanity. And if you gave a pass on the first guy, you save all of humanity. Anyway, I hope you found that one enjoyable. This is one of my favorite brain teasers. And I apologize because I realize when I was trying to explain it without the example, it might have gotten a little confusing. But hopefully this example explains things a little bit better. Although it might be confusing to see green and purple written in blue. See you in the next video.