Their are 10 prisoners in a jail for a minor crime, they all request the jail officer to set them free, jail officer agrees to release them tomorrow, saying i will
- Make you all stand in a queue in ascending order of your heights(smallest first).
- You will not be allowed to turn your head(they have to look straight)
- I will put one hat on your head, either BLACK or WHITE in color.
- Everyone of you has to tell the color of his hat starting from the tallest prisoner, you can only say BLACK or WHITE.
- You all will be released, if and only if at least 9 of you guess your hat’s color correctly.
Can you suggest a strategy to the prisoners to maximize the chances of their release?
10 prisoners and hats puzzle solution:-
I would suggest, think once again before reading the solution
Okay, If you tried enough:-
- The strategy is to count the number of white and black hats in front of them and say white if number of white hats are odd else say black.
- Now the next prisoner will count the white or black hats(depending on what the first person said) and if the count is even it means he has the same color hat else it is the opposite color hat.
- Now all other prisoner will keep making the count as odd or even depending on the previous prisoners answer and can predict their own hat color.
- This way, all prisoner will be able to guess the color of their hats correctly accept the first one, which will be having 50% probability.
In the above image:-
For the last prisoner=> number of white hats in front of him: 3(odd), so he will say white
For next prisoner: number of white hats in front of him: 3(odd), as the previous prisoner said white so it is black hat on his head.
Again for the next prisoner: number of white hats in front of him: 3(odd), as the the previous prisoner said black so it must be black hat on his head too.
Same logic for next 2 prisoners as well
Now the sixth prisoner from last see number of white hats as 2:(even)-> he can say it is his hat which was making the white at count odd, so his hat must be white in color.
Seventh prisoner can see now white hat count for previous prisoner is even and can predict the color of his hat.