# There are four men A, B, C and D buried up to their necks in the ground in a straight line. Between A & B there is an opaque wall. They cannot move and can only look forward such that A and B can only see their respective sides of the wall, C can see B, and D can see B and C. They are all aware that each of them is wearing a hat, and that two of them are wearing a black hats while the other two are wearing white hats. They don’t know what color they are wearing. In order to avoid being executed, one of them must call out to the executioner the color of their hat. If they get it wrong, everyone will be shot. After 60 seconds, one of them calls out. Which one of them calls out? How can he be certain he knows the color of his hat? There’s no outside influence and no other way of communicating.

**Updated:**Sept. 21, 2023 —

**Training Time:**2 minutes

Overseen by: Archangel Macsika

**Topic:** Data Science.

**Difficulty:** Easy.

**Companies who previously asked this:** -

**Objective:** There are four men A, B, C and D buried up to their necks in the ground in a straight line. Between A & B there is an opaque wall. They cannot move and can only look forward such that A and B can only see their respective sides of the wall, C can see B, and D can see B and C. They are all aware that each of them is wearing a hat, and that two of them are wearing a black hats while the other two are wearing white hats. They don’t know what color they are wearing. In order to avoid being executed, one of them must call out to the executioner the color of their hat. If they get it wrong, everyone will be shot. After 60 seconds, one of them calls out. Which one of them calls out? How can he be certain he knows the color of his hat? There’s no outside influence and no other way of communicating.

**Short Answer: C**.

### Full Solution

First, we will rule out A and B because neither of them can determine the color of the hat in their current position since both can only see an opaque wall.

D can see the color of the hat of B and C but not his. So there's no way D can be certain except B and C wears same color of hat.

C has the best chance of calling out the answer with the highest level of certainty.

To know why he's certain, let's assume he called out that he's wearing a white hat.

C knows that D can see the color of the hats of B and C.

Knowing this, if B and C wore the same color of hat e.g both have white hats, D will immediately call out the black color of hat as his.

However, D remained silent, and as a result, C realized that he must be wearing a different color of hat from B.

Hence, if B is wearing a black hat, then C is wearing a white hat.