There are 50 prisoners in a jail sentenced to death. One day before the execution, the jailer gives them a chance to live if they all work on a strategy together. The execution scenario is as follows:
On the day of execution, all the prisoners will be made to stand in a straight line such that one prisoner stands just behind another and so on. All prisoners will be wearing a hat either of Yellow colour or Orange. The prisoners do not know what colour of hat they are wearing. The prisoner who is standing at the last can see all the prisoners in front of him (and what colour of hat they are wearing). A prisoner can see all the hats in front of him. The prisoner who is standing in the front of the line cannot see anything.
The jailer will ask each prisoner what colour of hat they are wearing one by one, starting from the last in the line. The prisoner can only speak “Orange” or “Yellow”. He cannot say anything else. If he gets it right, he lives otherwise he is shot instantly. All the prisoners standing in front of him can hear the answers and gunshots.
Assuming that the prisoners are intelligent and would stick to the plan, what strategy would the prisoners
makeover the day/night to minimize the number of deaths?