# Alien Abduction Brain Teaser [duplicate]

Okay Here is the brain teaser.

10 people have been abducted by aliens because they view them as being representative of the human race. They are going to test them to see if the human race is worthy of entering the intergalactic council of planets and if they are not they are going to kill all the people and turn earth into a mushroom farm because that's their oil. Already sounds scary doesn't it? And so they take them in their spaceship and say "You ten represent all of humanity and the fate of humanity rests in your hands. We will give you a test and the test is tomorrow. 24 hours from right now we are going to put you all in a dark room and line you up 1 behind the other. Each person will once the lights are turned on able to see only the back of the heads of the people in front of him. While the room is pitch dark we are going to place a hat on each of your heads and it will either be purple or green. The hats are designed in such a way that you can't see your own hat. The distribution of the hats will be random. They are going to start with the person in the back and ask "What color is the hat on your head?" and he has to say it with an even tone. He can however say it as loud as he wants. Everyone is going to hear what everyone is going to say. If you are right you will live and all the people you represent will also live and won't be turned into a mushroom farm but if you are wrong you will die and the people you represent will also die and the land they are on will turn into a mushroom farm. so they say "We are going to do this tomorrow and your goal is to save as many people as possible. You have 24 hours to discuss this and come up with a system so that when we put you in the dark room and we put hats on each of your heads and then turn on the lights. If any of the 10 people cheat they will kill us all and turn the whole earth into a mushroom farm. Now in the next 24 hours they come up with a system in which the person in the back counts the number of green hats only and if it is odd he will say green and if it is even he will say purple and then other people deduce the color of their hats based on what the other people say.

Like for example: G = green P = purple G P P G G P G G P P The guy in the back sees an odd number of green hats and so he will say green and get displaced. The second guy sees an odd number of green hats and he will say purple. and on and on and on through a binary tree with 2^1 + 2^2 + 2^3 ... + 2^9 + 2^10 branches

Now my question is can you make this brain teaser work for any number of colors.

Like for example lets say we have Red, Orange, Yellow, Green, Blue, and Purple hats.

Can you make a system that branches from 1 color to the next and will save at least 9 people if not more?

-

## marked as duplicate by Rahul, Ross Millikan, vonbrand, Jack D'Aurizio, ShuchangMar 6 at 3:07

Let there be $n$ colors of hat. Match them to the numbers $0$ through $n-1$. The rear person adds up the numbers corresponding to the hats he sees modulo $n$ and guesses that color. He has $\frac 1n$ chance to survive. Each other person in turn does the same computation and can determine the color of his hat to make the sum match what the person behind him said. They all get it right.