You are one of 20 prisoners on death row with the execution date for tomorrow. Your king is a ruthless man who likes to toy with his prisoners. He comes to your cell and tells you: �I�m gonna give you prisoners a chance to go free tomorrow. You will all stand in a queue before the executioner and we will put a hat on your head, either a red or a black one. Of course you will not be able to see the color of your own hat; you will only be able to see the prisoners in front of you with their hats on; you will not be allowed to look back or communicate together in any way (talking, touching) The prisoner in the back will be able to see the 19 prisoners in front of him. The one in front of him will be able to see 18.
Starting with the last person in the row, he will be asked a question: WHAT IS THE COLOUR OF YOUR HAT?
He will be only allowed to answer �BLACK� or �RED�. If he says anything else you will be executed. If you say the wrong colour you are executed, you are set free if you get the right one
Can you come up with a plan to ensure the safety of most of your cellmates?