I don't want to harp on the hat riddle but I believe I figured out a satisfactory answer. The first person simply says the color of hats that is even, since there is an odd number of people ahead of him (9) the combination of hat colors must consist of an even number of one color of hat and an odd number of another color of hat.
To illustrate here is an example. (When I say first person, second person, etc. I am starting from left to right)
W | W B B B W W B B B
The first person is only important in letting the others know what color hat they are wearing. In this situation the first person will say Black, since there is an even number of black hats. This means that there must be an odd number of white hats, as a mathematical principal (an odd number broken up in 2 whole numbers must consist of an even number and an odd number).
The second person will see that there are 6 B ahead, meaning that if he was black there would be an odd number of blacks. Therefore he is WHITE.
The third person knows there is 1 white behind him and since he sees 5 B ahead of him he knows he must be B to make the total number of B even.
This pattern continues so on and so fourth.
After considering this example you might ask what would happen in the following situation:
W| B B B B B B B B B
In this case, the first person would say white.
The second person would see that there 8 B ahead of him, meaning that if he were W it would still be an odd number of whites contradicting the first person, therefore he is B.
The third person would see 7 B ahead of him and knowing there was 1 B behind him and 7 B ahead, if he was white he would realize that there would still be an odd number of white contradicting the first person.
This occurs so on and so fourth so that everyone will know they are Black.
SO THE RULE IS:::::: Say the number of even hats, and if they are all odd (all the hats are the same color) say the opposite color
Furthermore, with a slight alteration in rule, it is possible to save N-1 people for N number of total people (everyone can be saved except the first guy who gets the short straw unfortunately)
Let's take 2 cases.
Case 1 we already described for an even number of people, (it happened to be 10 in total).
Case 2 is for an odd number of people.
For an odd number of people there are the following possibilities:
2 groups both odd
2 groups both even
And to be thorough- 1 group even but that will fall into place as if 1 group was all odd as in above case.
This time, the first person will designate a color to stand for whether there are 2 groups of odd colors, or 2 groups of even colors.
Let's say that Black stands for Even and White stands for Odd
Again, the easiest way to illustrate is perhaps by example and for an example we shall choose a managable number to work with. There are 5 people.
B | W B B W
The first person will say Black since there are 2 groups of even (2 whites and 2 blacks)
The first person will see 1 W and will know he is W to make an even.
For 2 odds it can easily be seen the same will work (1st person will say black).
How about for:
B | W W W W
The first person will say Black meaning there 2 groups of evens.
The second person will see that there are 3 W ahead of him. This is not possible to form 2 groups of evens. Therefore he assumes that they are all white as similar to Case I where n=even number.
There are 2 possible cases. Case I: The total # of people is even. Case II: The total # of people is odd.
In Case I (2n from i=1 to i=infinity where i=1,2,3...etc.) the first person will say the color corresponding to the even number of hats. If there is only 1 group of odd hats, the person will say the opposite color.
In Case II (2n+1 from i=1 to i=infinity where i=1,2,3...etc.) the person will designate a color to signify two groups of even hats or a color to signify two groups of odd hats. If all hats are the same the person will say the color signifying two groups of evens.
Edited by c7ng23, 28 October 2006 - 10:48 PM.