Welcome to techInterview, a site for technical interview questions, brain teasers, puzzles, quizzles (whatever the heck those are) and other things that make you think!
I buried four fishermen up to their necks in the sand on the beach at low tide for keeping their fishing spot a secret from me. I put a hat on each of their heads and told them that one of them must shout out the correct color of their own hat or they will all be drowned by the incoming tide. I give them 10 minutes to do this. Fisherman A and B can only see the sand dune I erected. Fisherman C can see that fisherman B has a white hat on. Fisherman D can see that C has a black hat, and B has a white hat. The fisherman have been told that there are four hats, two white and two black, so they know that they must have either a white or a black hat on. who shouts out the color of their hat and how do they know?
Fisherman C shouts out.
Fishermen A and B are in the same situation - they have no information to help them determine their hat colour so they can’t answer. C and D realise this.
Fisherman D can see both B and C’s hats. If B and C had the same colour hat then this would let D know that he must have the other colour.
When the time is nearly up, or maybe before, C realises that D isn’t going to answer because he can’t. C realises that his hat must be different to B’s otherwise D would have answered. C therefore concludes that he has a black hat because he can see B’s white one.