# Enigmatic Code

Programming Enigma Puzzles

## Puzzle #31: Three hats

From New Scientist #3257, 23rd November 2019 [link] [link]

Ariana, Beverley and Cassie are standing in a line. They know that two of them are wearing black hats and one is wearing a white hat — or vice versa — in an arrangement like the one shown above.

Beverley and Cassie can see the hats in front of them but not behind, while Ariana can’t see any hats. They can only say “white” or “black” to announce their own hat colour.

Who will be able to confidently state their hat’s colour first? And who will be second?

[puzzle#31]

### 2 responses to “Puzzle #31: Three hats”

1. Jim Randell 23 November 2019 at 8:37 am

I am assuming the participants only know that the hats are black or white, and that there is at least one hat of each colour.

Initially A doesn’t have any further information, so can’t say anything.

B can see the colour of A‘s hat, but there is at least one hat of each colour so they can’t say anything either.

C can see the colours of A‘s hat and B‘s hat. If C sees two hats the same colour (i.e. two black hats or two white hats), then they know that their own hat must be the other colour, so can state their colour immediately, and if this happens both A and B know that their two hats must be the colour that C didn’t state, so each can then state the colour of their own hat.

Scenario 1: A=X, B=X, C=Y
[1] C declares Y
[2] A and B declare X

However, if C sees two hats of different colours, then they do not know the colour of their own hat, and cannot declare immediately. Both A and B on hearing the pause know that their own hats must be of different colours, so B can then declare the colour of their hat (it’s the colour that A‘s isn’t), and A can then declare the colour of their hat (it’s the colour that B‘s isn’t). C still doesn’t know what colour their hat is.

Scenario 2: A=X, B=Y, C=?
[1] <pause>
[2] B declares Y
[3] A declares X

If they are wearing hats as shown in the diagram, then they are in a Scenario 2 situation. So:

Solution: Beverley declares first. Ariana declares second.

2. Hugh Casement 25 November 2019 at 7:09 am

Translated into English:

If C sees two hats the same colour (i.e. two black hats or two white hats), then she knows that her own hat must be the other colour, so can state her colour immediately; if that happens both A and B know that their two hats must be the colour that C didn’t state, so each can then state the colour of her own hat.
[…]
However, if C sees two hats of different colours, then she does not know the colour of her own hat, and cannot declare immediately. Both A and B on hearing the pause know that their own hats must be of different colours, so B can then declare the colour of her hat (it’s the colour that A‘s isn’t), and A can then declare the colour of her hat (it’s the colour that B‘s isn’t). C still doesn’t know what colour her hat is.

That’s rather less confusing now!

This site uses Akismet to reduce spam. Learn how your comment data is processed.