# Ernest does not know the color of his hat (3)

(again a more a difficult one)
The (same) premise: An unknown number of people stands on a line playing a hat guessing game

• they may not move during the game, they can only look straight ahead (each person in a direction along the line, i.e. right or left depending on their facings)
• they all wear a yellow, a red or a green hat.
• they see all people in front of them
• they do not know their own hat
• they do not know anything about the configuration behind them, except which people are there, and what is deduced from the content of the statements
• all statements are provably true for the person uttering them

Anna says: The person 1 (i.e. directly) before Fay wears a red hat
Bob says: The person 2 before me wears a green hat
Carole says: The person 4 before me wears a yellow hat

EDIT : I made a mistake twice in Fays statement D and E were wrongly one way earlier I'm so sorry..
Fay says: Dennis is directly behind Ernest and vice versa.

then Dennis says: Ernest does not know the color of his hat
then Ernest says: I know the color of my hat

Note: Since it is not clear to everyone: The then in the last two statements mean that it matters that Dennis it the fourth and Ernest the fifth/last to talk.

• Given that the statements cannot be true with less people than present, how do they stand?
(i.e. Give the order and directions; not all hat colors are known)

A hint to make life easier

The number of persons can immediately be determined

It is

There are 6 persons.

Why

This because all facings are stated (by me) to be deducible. The facings of unmentioned persons are not mentioned in any way in the hints, so only the mentioned persons can be present. Note that if this was not noticed, it would still be reasonable to assume 6 until contradiction, since we are looking for a minimal number.

The most important thing to realize:

Dennis' statement gives Ernest information. This excludes a lot of possibilities. Even if it is not clear yet how Ernest deduces his hat color from the information, Dennis must be passing him useful information (that can be combined with other information to give him his hat color).

• Re: "Fay says Ernest is directly behind Dennis". Does this mean that Dennis has his back to Ernest, or that Fay sees Dennis somewhere in front of her, and Ernest is one position closer to her? I can see a solution for the second case but not the first one. Oct 12, 2020 at 22:19
• It means the first. Now you ask it, I can see it might be unclear. I will edit it. Oct 13, 2020 at 6:41
• Hmmm, I don't think it's possible because the number of people in total is unknown, wait... Oh, now I'm getting somewhere. Sorry ;)
– user71418
Oct 13, 2020 at 8:26
• With this edit, is it possible that Dennis can see Ernest (i.e, they are facing the same way)? Oct 15, 2020 at 15:40
• @hexomino Only one facing will be possible, considering the statements. I've proven that I am not perfect, but the problem is now as intended, and I am convinced it is correct now. Oct 15, 2020 at 15:44

Okay, the new edit makes me think I know the answer but it hinges on the following premise

Dennis can only make his statement after Fay has stated "Dennis is directly behind Ernest" and Ernest knows this.

In that case they must stand like this

$$A> \text{ }B> \text{ } \text{ }

which makes Ernest's hat

Green

Reasoning

Before Fay speaks Dennis cannot make his statement (see the premise). Hence, Dennis and Ernest must be back-to-back, otherwise Dennis will know beforehand that Ernest cannot state the colour of his hat.
If there is nobody in front of Ernest, then Ernest will have no chance of guessing his hat colour at the end. Similarly, if there is one person in front of Ernest who is not Carol, then either Ernest will be uncertain (if they see a yellow hat in front) or will know he has yellow if the hat colour in front is different, in which case Dennis cannot be certain that Ernest does not know the colour of his hat. Hence, Ernest has at least two people in front.
Similarly, if Dennis does not have at least two in front of him, he cannot determine for certain if Ernest does not know the colour of his hat (this is easily analysed on a case-by-case basis). Hence, both Dennis and Ernest must have two people in front of them.
Bob must be somewhere in front of Dennis because otherwise Dennis could not be sure that Ernest does not know his hat is green. If Fay is somewhere in front of Dennis, then there are at least a pair of scenarios which Ernest will not be able to distinguish. Hence, Fay is somewhere in front of Ernest and must be two ahead for Dennis to be able to make his statement. Furthermore, Dennis must know this, so the only configuration is that Carol is in front of Ernest and Dennis knows this because Dennis sees a yellow hat two in front.
Finally, we must distinguish the positions of Anna and Bob. Again, this hinges on the premise. If Anna were directly in front of Dennis then Dennis would be able to determine that Ernest does not know the colour of his hat before Fay speaks. However, this is not the case. Hence, Bob must be directly in front of Dennis (facing him to have at least two people in front) with Anna at the end. Hence, Ernest can deduce, just at the end, that his hat is green

Why did people not solve this sooner.

My guess is that the premise in this answer is not obvious to the regular solver (it was not obvious to me) and perhaps should have been more explicitly stated.

• Could you explain the A vs B step in more detail? If A's hat is not y, why can't their positions be swapped? Even with the premise (not obvious is quite an understatement btw.) we'd have D knows E does not know, D couldn't know before F because he couldn't rule out B> A> <D F> <C <E. So E cannot from D's statetment infer the positions of A vs B and cannot infer his hat. Am I missing something? Oct 18, 2020 at 10:57
• In the configuration you give above, D has enough information to say "E does not know the colour of his hat" before Fay speaks so we can rule out this configuration. Honestly, I'm not 100% on my answer as the B vs A part is somewhat confusing. Oct 18, 2020 at 11:17
• Ah, I see now, even though E sees "everything" he still cannot know his hat in this config. Thanks. Oct 18, 2020 at 11:20
• The premise is correct and the order stated by the then in then Dennis.. then Ernest, I will make it more clear. The answer however, is incorrect. As far as Ernest knows A and B could be swapped while A is wearing a non-yellow hat; then Dennis knows F refers to Cs hat and can make his statement. Oct 18, 2020 at 11:42
• @Retudin If A and B are swapped then Dennis can be sure E does not know the hat colour before F speaks because C is known to break E and F. This allows E to distinguish the scenarios. Oct 18, 2020 at 11:48