# Another hats and prisoners puzzle

• micromass
In summary, the conversation discusses a puzzle where individuals must correctly identify the color of their hat to go free. One person introduces shorthand notation for the setup and there is a disagreement about the exact rules of the puzzle. The conversation ends with someone realizing their solution missed something and questioning if everyone goes free if they are correct or only upon shouting the color of their own hat.

#### micromass

Staff Emeritus
Homework Helper

Prisoner 2 will yell out first
2 see's that 3 has a black hat
IF 2 was also wearing a black hat 1 could yell out he has a white hat since he see's both black hats and would know he must have a white hat.
Since 1 doesn't yell. He can assume that 1 see's both a white and black hat in front of him

Hope that's right :) makes sense though

micromass
If man 1 sees that men 2 and 3 have hats of the same color, he knows that he has a hat of the other color. So he can shout out the color of his hat.
If after a while man 1 remains silent, man 2 understands that man 1 is seeing hats of different colors on him and on man 3. As man 2 sees the color of man 3's hat, he knows that his hat has the other color, and can shout it.
In the setup of the question, it would thus be man 2 who shouts first.

micromass
Are the hats placed as drawn, or is it just an example?

Borek said:
Are the hats placed as drawn, or is it just an example?

As drawn. But you can of course try to find the solution of every permutation of hats!

1) If man 1 does not yell, then man 2 knows his hat is opposite of man 3
2) Given the picture, man 2 will yell first
3) This will indicate that man 1 and 3 have the same color hat, prompting man 1 to yell
4) Man 3 will then yell
5) Man 4 is sh*t out of luck because even if he did yell he is still stuck behind that wall

micromass said:
As drawn. But you can of course try to find the solution of every permutation of hats!

I think there are just two solutions.

OrangeDog said:
1) If man 1 does not yell, then man 2 knows his hat is opposite of man 3
2) Given the picture, man 2 will yell first
3) This will indicate that man 1 and 3 have the same color hat, prompting man 1 to yell
4) Man 3 will then yell
5) Man 4 is sh*t out of luck because even if he did yell he is still stuck behind that wall

There's a minor mistake in there.
In step 3 you say man 1 should yell, but how would he know if he has the same color as 2 or 3?
In fact the only one that can yell (with certainty) is number 3 knowing he has the opposite color of 2.

Let me introduce some shorthand notation for the setup, the nth letter in the string "BWB | W" indicates the color of person n.

Case 1: "BWB | W" or "WBW | B"
The answer has been given above, number 1 and 4 have to gamble if they want to go free (I think?)

Case 2: "WWB | B" or "BBW | W"
See case 1 :P

Case 3: "WBB | W" or "BWW | B"

- Person 1 can yell out its color immediately since he sees both hats of the color opposite to his in front of him.
- Person 2 and 3 know their hat has the opposite color
- Person 4 knows he has the same color as person 2

That's about it. Although I recall a different puzzle, those that call out their color correctly go free, those that are wrong or silent get sentenced to death.

How many of you clicked to see the 3 cases?

JorisL said:
There's a minor mistake in there.
In step 3 you say man 1 should yell, but how would he know if he has the same color as 2 or 3?
In fact the only one that can yell (with certainty) is number 3 knowing he has the opposite color of 2.

Let me introduce some shorthand notation for the setup, the nth letter in the string "BWB | W" indicates the color of person n.

Case 1: "BWB | W" or "WBW | B"
The answer has been given above, number 1 and 4 have to gamble if they want to go free (I think?)

Case 2: "WWB | B" or "BBW | W"
See case 1 :P

Case 3: "WBB | W" or "BWW | B"

- Person 1 can yell out its color immediately since he sees both hats of the color opposite to his in front of him.
- Person 2 and 3 know their hat has the opposite color
- Person 4 knows he has the same color as person 2

That's about it. Although I recall a different puzzle, those that call out their color correctly go free, those that are wrong or silent get sentenced to death.

How many of you clicked to see the 3 cases?

I disagree with you.
If man 1 does not yell, man 2 can see man 3's hat. Therefore, man 2 knows that he must have the opposite color of man 3. Man 2 can then shout his color. Since man 2 has left the area, and there are only two colors of hats, by process of elimination man 3 must have the same color hat as man 1. Man 1 can confirm this but man 3 cannot. When man 1 leaves, man 3 knows that man 1 cannot see over the wall, so therefore the only way man 1 could have known his hat color is if the color of man 3's hat matched the color of man 1. Man three therefore knows his color and can leave too. Man 4, I don't think he can do anything.

@OrangeDog are you sure?
Guy 2 has left.
So at this point Guy 1 knows the colour of #3 and #2. He has no additional info than he did at the start...

Oops. I saw it in my head somehow though. Maybe I was thinking of the picture as I said it lol.

If prisoner number one sees that two and three have hats of the same colour, he can conclude that his hat is of the opposite colour and will shout first.

If prisoner number one sees that two and three have hats of different colours, the probability of a correct guess on his part is 0.5, so he will not shout.

Hearing no shout (after a long enough period of time), prisoner number two can conclude that his hat is a different colour than that on prisoner number three. So, once he has not heard anything from number one (assuming that he can count on number one to be timely with an accurate answer if one is available), he will be the first to shout out the colour of his hat - opposite to that of prisoner number three.

As drawn, prisoner number two would be the first to shout.

Instead of sleeping in this morning like normal people do on a Saturday. My brain woke me up and insisted on thinking of this problem. Realized that my solution (and the ones I checked. All missed something (in the setup as shown)

After 2 yells and is let go
Number 3 can assume since 1 didn't yell he has a different colour hat than 2, and can yell opposite from whatever 2 had.

1 and 4 are up the creek without a paddle

Well the exact rules aren't very clear. It asks who would shout first. But does this mean all go free if they are correct?
Or do they go free upon shouting the colour of their own hat?

## What is the "Another hats and prisoners puzzle"?

The "Another hats and prisoners puzzle" is a logic puzzle that involves a group of prisoners who are given the opportunity to save themselves by correctly guessing the color of their own hat.

## How many prisoners are involved in the puzzle?

There are an infinite number of prisoners in the puzzle, but only a finite number are given hats.

## What is the objective of the puzzle?

The objective of the puzzle is for the prisoners to correctly guess the color of their own hats. If at least one prisoner guesses correctly, all prisoners will be set free. However, if no one guesses correctly, all prisoners will be executed.

## What are the rules of the puzzle?

The rules of the puzzle are as follows:

• The prisoners are not allowed to communicate with each other once the puzzle begins.
• The prisoners are lined up in a single file, facing forward.
• The prisoners are all given either a black or white hat, but they cannot see the color of their own hat.
• No one is allowed to remove their hat or look at the color of their own hat.
• The prisoners can only see the hats of the prisoners in front of them.
• The prisoner at the back of the line can see all of the hats in front of them.

## How can the prisoners solve the puzzle?

The prisoners can solve the puzzle by using a strategic guess, based on the color of the hats they can see in front of them. By observing the colors of the hats in front of them and the number of hats of each color, they can make an educated guess about the color of their own hat. However, there is no guaranteed solution to the puzzle, as it relies on chance and probability.