Logic Puzzles

2. The Stark Raving Mad King

A stark raving mad king tells his 100 wisest men he is about to line them up and that he will place either a red or blue hat on each of their heads. Once lined up, they must not communicate amongst themselves. Nor may they attempt to look behind them or remove their own hat.

The king tells the wise men that they will be able to see all the hats in front of them. They will not be able to see the color of their own hat or the hats behind them, although they will be able to hear the answers from all those behind them.

The king will then start with the wise man in the back and ask "what color is your hat?" The wise man will only be allowed to answer "red" or "blue," nothing more. If the answer is incorrect then the wise man will be silently killed. If the answer is correct then the wise man may live but must remain absolutely silent.

The king will then move on to the next wise man and repeat the question.

The king makes it clear that if anyone breaks the rules then all the wise men will die, then allows the wise men to consult before lining them up. The king listens in while the wise men consult each other to make sure they don't devise a plan to cheat. To communicate anything more than their guess of red or blue by coughing or shuffling would be breaking the rules.

What is the maximum number of men they can be guaranteed to save?

Added 1 January 2007

Hint:

To solve this problem, you need to presume that each wise man can count the total number of red hats in front of them without error, that all the wise men have great attention to detail and that all the wise men care about the greater good.

Solution:

99.

You can save about 50% by having everyone guess randomly.

You can save 50% or more if every even person agrees to call out the color of the hat in front of them. That way the person in front knows what color their hat is, and if the person behind also has the same colored hat then both will survive.

So how can 99 people be saved? The first wise man counts all the red hats he can see (Q) and then answers "blue" if the number is odd or "red" if the number is even. Each subsequent wise man keeps track of the number of red hats known to have been saved from behind (X), and counts the number of red hats in front (Y).

If Q was even, and if X&Y are either both even or are both odd, then the wise man would answer blue. Otherwise the wise man would answer red.

If Q was odd, and if X&Y are either both even or are both odd, then the wise man would answer red. Otherwise the wise man would answer blue.

There can be any number of red hats, as the following examples show...

Prisoner Hat he wears Number of red hats he sees (Y) Red hats saved for sure (X) He says
1 red 6 even (Q)  

N/A

red
2 blue 6 even 0 even blue
3 red 5 odd 0 even red
4 blue 5 odd 1 odd blue
5 blue 5 odd 1 odd blue
6 red 4 even 1 odd red
7 red 3 odd 2 even red
8 red 2 even 3 odd red
9 red 1 odd 4 even red
10 red 0 even 5 odd red

Another example might also help, as this puzzle seems to trip up most people...

Prisoner Hat he wears Number of red hats he sees (Y) Red hats saved for sure (X) He says
1 blue 5 odd (Q)   N/A blue
2 blue 5 odd 0 even blue
3 red 4 even 0 even red
4 blue 4 even 1 odd blue
5 blue 4 even 1 odd blue
6 red 3 odd 1 odd red
7 blue 3 odd 2 even blue
8 red 2 even 2 even red
9 red 1 odd 3 odd red
10 red 0 even 3 odd red

 


Comments (19)

Anonymous 18 May 2007

In a scenario with 10 wise men, the first can see all hats in front and deduce his own color, allowing each subsequent man to do the same based on the visible hats.

Anonymous 13 September 2007

Regarding The Stark Raving Mad King, I believe there's a missing element in the explanation. The question implies uncertainty about the red/blue hat ratio and the survival of those behind. The first person asked has no basis for their answer, which complicates the outcome.

Anonymous 30 September 2007

Initially, I thought the solution was wrong, but I realized that the wise men can keep track of the number of red hats saved based on the rules they prepared.

Anonymous 30 September 2007

There seems to be a missing element in the explanation, as the wise men do not know the red/blue ratio or whether those behind them survived.

Anonymous 30 September 2007

The explanation lacks clarity regarding the unknowns, such as the red/blue ratio and the survival status of those behind them.

Anonymous 15 February 2009

I spent a half hour on The Stark Raving Mad King and was frustrated when the solution didn't show up.

Anonymous 29 June 2009

The example of 3 prisoners in the Warden puzzle is incorrect. The leader needs to count 4 switches to ensure all prisoners have visited the room.

Anonymous 17 May 2013

The solution to The Stark Raving Mad King is incorrect. The wise men cannot know whether a previous wise man was killed, which contradicts the solution's claim that they keep track of red hats.

Anonymous 17 May 2013

The solution to The Stark Raving Mad King is incorrect. The wise men do not know whether the man before them survived based on the rules they prepared, which contradicts the solution's statement about tracking red hats.

Anonymous 21 May 2013

You should mention in the 'Stark Raving Mad King' puzzle that there is an equal number of each colored hat.

Anonymous 13 December 2013

You did not specify that the number of blue and red hats will be the same.

Anonymous 10 June 2014

In the mad King puzzle, it should be clarified that there are 50 red and 50 blue hats.

Anonymous 29 December 2014

The solution suggests that participants can keep track of the number of red hats saved, but it's unclear how they can do this if the person is silently killed and they can only hear the previous answer.

Anonymous 25 April 2015

The puzzle about the king and the hats lacks clarity. There is no mention of equal or odd numbers of red and blue hats, making it poorly constructed.

Anonymous 25 April 2015

The puzzle is unsolvable without stating that there are an equal number of red and blue hats, which was omitted. This led to significant confusion and wasted time.

Anonymous 25 April 2015

It seems impossible for the wise men to keep track of the number of red hats saved if they can only hear the previous answer and not see the outcomes.

Anonymous 25 April 2015

I believe the actual number of guaranteed survivors should be 93, as the wise men can hear the answers from those behind them, which affects their knowledge.

Anonymous 25 April 2015

The puzzle titled 'The Stark Raving Mad King' does not give the correct answer. I have attached the puzzle and your suggested answer along with a scenario that shows the error.

Anonymous 8 April 2020

On the very difficult logic puzzle about the Mad King and his 100 wise men, I found another way to guarantee saving 99 of the men. They can all hear the answer of the person behind them, so the first person looks at the color of the hat in front of him and coughs or shuffles accordingly. That tells the person in front what colour his hat is. The process continues all the way down the line, with every wise man guaranteed to survive except for the person at the very back, who has a 50% chance to survive.

Add a Comment or Suggest an Answer



« Back to Logic Puzzles


Puzzles

Site Map | Contact Us