The Puzzle of 100 Hats
100 persons are standing in line, each facing the same way. Each person is wearing a hat, either red or blue, but the hat color is not known to the person wearing the hat. In fact, a person knows the hat color only of those persons standing ahead of him in line.
Starting from the back of the line (that is, with the person who can see the hat colors of all of other 99 persons), in order, and ending with the person at the head of the line (that is, with the person who can see the hat color of no one), each person exclaims either “red” or “blue”. These exclamations can be heard by all. Once everyone has spoken, a score is calculated, equal to the number of persons whose exclamation accurately describes their own hat color.
What strategy should the 100 persons use in order to get as high a score as possible, regardless of how the hat colors are assigned? (That is, what strategy achieves the best worst-case score?)
For example, if everyone exclaims “red”, the worst-case score is 0. If the first 99 persons exclaim the color of the hat of the person at the head of the line and the person at the head of the line then exclaims the color he has heard, the worst-case score is 1. If every other person exclaims the hat color of the person immediate in front and that person then repeats the color he has just heard, then the worst-case score is 50. Can you do better?
Hint: Instead of using just red and blue as the possible hat colors and exclamations, use N different colors.
The person standing at the back of the line can see all the people. I think it is important to consider that this problem has specifically 100 people in it, instead of some variable amount. This means the person in the back can see 99 people in blue and red hats in front of him. Since there are an odd number of hats the last person can see, it means that:
1. The number of red and blue hats the last person can see is not equal.
2. Either the red or the blue hats contain an odd number of hats, but not both.
With this in mind, we will be able to consistently communicate hat colors to all the participants. The person in the back of the line will begin by counting all the hats, and saying whatever color has an odd number of hats. The second person will then be able to count the hats in front of him (meaning all hats the last person saw minus the one he is wearing) if he sees an even number of the same color the first person said, he must be wearing that colored hat, otherwise he is wearing the other colored hat.
For example, if the person in the back sees an odd number of red hats, he will declare “red”. The second to last person will then count the amount of red hats he sees, if he sees an odd number, it means he is wearing a blue hat, if he sees an even number, it means he is wearing a red hat.
This process will work if every person in line keeps track of which colors have an odd or even count. Thus the worst case for this solution is 99, since the person at the front will answer solely based on what is in front of him, he will have a 50% chance of guessing correctly.
Actually, this solution works for any number of people standing in the line, they just have to agree first on the specific color of the hats they would be counting.
How we can be sure with the odd even formula. Are both the hats are of same count. 50 blue + 50 red.
If not:
Suppose there are 51 blue hats and 49 red hats. And last person wear red hat, then he counts blue as odd and speak aloud blue, that is wrong.
absolutely agree with VIKASB. Nowhere does it say that there’s 50-50 red-blue distribution -> “Each person is wearing a hat, either red or blue”
based on this the distribution is completely random, could be 99-1 for example.
Solution provided by RONIT is nice, but not correct in general case.

Its correct for all cases. The person at last can see either one of the red or blue hats as odd for any distribution.
If distribution is 99-1 then he sees 99 hats of same color (lets say red) then he will say red(ofcourse he is wrong of his own hat color which is blue) and respectively the 99th person sees 98(even) hats of same color therefore he is sure that he is wearing red hat and similarly everyone will debug the color of his hat
Your Answer
More puzzles to try-
Solve the Algebraic (J+O+I+N+T)3 = JOINT riddle
Solve the Algebraic mathematical equation, To find value of INT? (J+O+I+N+T)3 = JOINT Find the solution for – INT = ...Read More »Red Light
What does SHOP spell? What does PROP spell? What does CROP spell? What does DROP spell? What do you do ...Read More »New York Traffic Laws puzzle
A bus driver was heading down a street in New York. He went right past a stop sign without stopping, ...Read More »Its Tasty but What is it?
There was a green house. Inside the green house there was a white house. Inside the white house there was ...Read More »The Search for Doman
This was astronaut Jose Perez’s fourth visit to Mars and he had learned to speak Martian. He wanted to find ...Read More »How is this possible?
Daniel, Claude and Lou are friends. Daniel is Claude’s brother. Claude is Lou’s brother. Lou is not Daniel’s brother. Question ...Read More »The Hematologist
After many years of looking through a microscope at human blood slides, a hematologist in a hospital laboratory is very ...Read More »Farmer getting across the river
A farmer needs to take a fox, a chicken, and a sack of grain across a river. The only way ...Read More »Tennis Gems
They are the five precious gems of an everyday sort and all can be found on a Tennis Court. Who ...Read More »Software Developer bounty prize puzzle
20 Software bug were given a bounty and assigned to a software developer. For each bug resolution, the software developer ...Read More »Prime Number Puzzle
It can be easily calculated that the digits 0 to 9 can be arranged into 3628800 distinct ten-digit numbers. But ...Read More »Lizards do not come Near
What is in the corner of a door that lizards do not come near?Read More »Clouds Hang around
It is easy to see, not easy to atop, Clouds hang around, and people like to slide down. What is ...Read More »True or False
Mark the below statements True or False ? 1. The Washington Monument is in Washington D.C.? 2. The Pacific Ocean ...Read More »Who killed the little boy?
There was a family who lived in a circle house, one day they went on vacation but they left their ...Read More »Interview with fun riddle
During an interview in a renowned company, while answering the question, the candidate became quite nervous. The interviewer was generous ...Read More »Finding name of the ancient king puzzle
500 at the beginning, 500 at the end, 5 in the middle is seen, The first of all letters, the ...Read More »Coded Name Puzzle
When I asked a girl’s name she told me her name is the date ’07/09/2001′. I thought for a few ...Read More »2 in 54
It is 2 in 54, five letter word, it is known as wild and some say unpredictable. It can raise ...Read More »I’m very smart and can be dangerous riddle
I’m a 8 letter word let’s say 12345678. I’m very smart and can be dangerous, My 78 is the name ...Read More »