In a really harsh prison the sadistic warden decided to give 100 prisoners the following task:
They must stand in a line, and he will put a hat on each of their heads. The hats can be either black or white. Then each prisoner will be allowed to say one word, either "black" or "white", trying to guess what hat he has. At the end of the game, all prisoners who got their color right will be released, all the rest will be killed. If any prisoner brakes any rule (looks backwards, says any other word, jumps , pokes, etc..) everyone will be killed.
What is their best strategy to get the minimum amount of prisoners killed ? How many prisoners are risking their lives using such a strategy?
The can decide on the stratagy ahead of time.
Again the rules. They all follow the algorithm. They can all hear what the fellow prisoners say. Each prisoner can see all the guys ahead of him , but non of those behind. They can all say either "black" or "white" once but the order of talking is
whatever they want. The number of black and white hats is unknown (but there are 100 hats in total).






What they could have decided is to let the first prisoner say BLACK if there is an even number of black hats that he sees in front of him, or WHITE if there is an odd number of them. (This also indicates whether there is an even or odd number of white hats since the total number of prisoners/hats is told.) The rest of the prisoners can thus deduce their hat colour one by one.
For example, if the first prisoner sees 45 white hats and 54 black hats, he would say BLACK - indicating that there is an even number of black hats and odd number of white hats. The second prisoner, by seeing 44 white hats and 54 black hats, would realise that there is no longer an odd number of white hats - and that he has a white hat. By saying WHITE, he saves his life while telling the next prisoner that there is now an even number of both black and white hats...etc.
Therefore the first prisoner is the only one who risks his life.