# Alien Abduction Brain Teaser [duplicate]

Okay Here is the brain teaser.

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 '14 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.