There is prison.
Imagine there are 100 prisoner in that prison including you.
One fine day the inspector comes and sets up a challenge for all of the 100 prisoner.
The challenge is that he will make you stand on a stair case which has 100 stairs.
Assume that you are on the 100th stair or the top most stair and the others are on the remaining stairs.
The inspector comes and put either a black or white hat on all of the prisoner. You have been told that there are only black and white hats but not told the number of black or white hats.
Then the inspector asks starting from you as your on the top that "What is the color of hat that your wearing?"You are either allowed to say black or white nothing else. Prisoners are not allowed to see there own hat nor they are allowed to see the hat of the prisoner behind him.
Each prisoner is only able to see the hats of the prisoners who are standing in front of him.
If your answer is correct then you are set free from the prison.But if your answer is wrong then you are killed.
Each prisoner is able to here the answer of all the other prisoner. All the prisoner including you are told about this challenge one day before. Thus you have to plan a strategy such that maximum of you all are set free and not killed.
So the question is "What is the maximum number of people you can save?"
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Only the one on the top will be killed(or he can stay alive if he is lucky). The strategy is The one on the top count the number of black hats. If its even, then the one on the topsays black, if its odd then says white. Then the rest will know wether number of black hats in the group of 99 people is odd or even,and they can count the number of blacks in front of them, thus they can confirm their hat color.