Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

This question already has an answer here:

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?

share|improve this question

marked as duplicate by Rahul, Ross Millikan, vonbrand, Jack D'Aurizio, Shuchang Mar 6 '14 at 3:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

well I don't think it is a duplicate because well for 1 thing I am using in the 2 colors example green and purple which aren't used in any others, not that combination anyway and I am asking if you can make a system that is a binary tree and branches from 1 color to the next for x colors and I have as an example for that the 6 colors of the rainbow. –  Caters Mar 6 '14 at 0:03
Doesn't have an answer for actually making the system. Just one for how many people are guaranteed to survive. –  Caters Mar 6 '14 at 0:19

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.