# The Puzzle of 100 Hats

1,530.4K Views

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.

ronret45 Expert Asked on 1st August 2015 in

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.

ronit Guru Answered on 5th August 2015.

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.

on 1st October 2015.

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.

on 9th March 2016.

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.

on 30th May 2016.

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

on 7th August 2016.

• ## More puzzles to try-

• ### Making Cigarette from its Buds

A beggar on the street can make one cigarette out of every 6 cigarette butts he finds. After one whole ...Read More »
• ### What is the word?

Pronounced as one letter,  And written with three,  Two letters there are,  And two only in me.  I’m double, I’m ...Read More »
• ### How many bounces will the ball take?

Donald Duck throws a ball from a 90 feet building. The ball is quite bouncy and when it hits the ...Read More »
• ### 6 Riddles Chanllenge

Whose birthday does not come every year? किसका जन्मदिन हर साल नहीं आता है? Which is the fruit that does ...Read More »
• ### Find the Hat in the Bathroom

You Are Highly Attentive If You Can Spot A Hat In This Bathroom In 9 Seconds!Read More »
• ### Present to Past

Can you name any English verb that becomes its past tense by simply rearranging the alphabets ?Read More »
• ### Learn English

By using ‘because’ continuously three times, can you make an English statement ?Read More »
• ### Know the age puzzle

Tony’s father is 45. He is 15 years older than twice Tony’s age. How old is Tony? John is twice ...Read More »
• ### The more you work, the more I’ll eat riddle

The more you work, the more I’ll eat. You keep me full, I’ll keep you neat. What am I?Read More »
• ### Heavy riddle

What gets heavier as you empty it?Read More »

• ### Score Prediction

I do not have any special powers, but I can predict the score of any football game before it begins. ...Read More »
• ### Fun Laughter Challenge

We know that money can be names differently for the purpose it is used for. Some of the examples of ...Read More »
• ### Agents Puzzle

Three spies, suspected as double agents, speak as follows when questioned: Albert: “Bertie is a mole.” Bertie: “Cedric is a ...Read More »
• ### I take what you receive

I take what you receive and surrender it all by waving my flag.What am I?Read More »
• ### James Bond Archer

James Bond is caught up in a mysterious scenario where the evil villain has him blindfolded. He somehow breaks through ...Read More »
• ### Love More Than Life

What does man love more than life, hate more than death or mortal strife; That which contented men desire; the ...Read More »
• ### Which Travels Faster

Which Travels Faster? Solve below famous picture riddle:Read More »
• ### Crystal Cage

The higher it climb, the hotter it engage, It can not escape its crystal cage. What is itRead More »
• ### Aliens in space riddle

There are three Federation Officers assigned to take three hostile aliens to “Peace Talks” on another planet. However, they must ...Read More »