**Q. **There are 10 prisoners and jailer said he will play a game with them next morning. He will make all of them stand in a row and put either of black or white hat on their head. Since, they are standing in a row, they can see the hats in front of them but not the one their head or heads behind them.

Starting from the last, jailer will ask each prisoner what is the color of his own hat. If prisoner gives wrong answer, he will shoot him right at that moment.

Prisoners have to come up with a strategy such that maximum of them can be saved.

**A. **

The last prisoner will say black if there are odd number of black hats in front of him. For simplicity, lets assume they are in odd number.

- Second last prisoner can count the black hats in front of him. If he gets odd number, he can conclude the hat on his head is white and black otherwise.
- Third last prisoner, will keep his ear open on the previous answer and then he’ll calculate of total black hats in front of him and behind him. That way he can decide if total is a odd number and can predict his hat’s color.
- Using this technique, n-1 prisoners can be guaranteed to be saved.

### Like this:

Like Loading...

*Related*

the question does not specify the total no. of hats. And answer assumes even no. of black hats.

Total number of hats will be same as number of prisoner. So, they know it.

The answer does not assume that there are even number of hats, its just for taking an example. This works even with odd number