So here’s a puzzle I read a short time ago. I came up with a solution that kinda worked, but then read a far better answer for it. Let’s see what you come up with.
There are 20 prisoners on death row, all set to be killed tomorrow. The executioner sets up this challenge:
“Tomorrow, all 20 prisoners will stand in a row. Each prisoner will be able to see only the prisoners standing in front of him/her. So the last prisoner will see all 19 in front, while the front prisoner will see no one. Each prisoner will then be given a hat, either WHITE or BLACK, placed on their head. You will not be able to see the color of your own hat, only those of the people in front of you. You will not be allowed to communicate in any way with anyone while standing in line, nor will you be able to turn or look at anyone but those in front of you. Violation of any of these rules will result in instant death for everyone.”
“Once this is all set, starting with the last prisoner in line, I will ask ‘What color is your hat?’ You can answer only ‘BLACK’ or ‘WHITE’, anything else means instant death for everyone. If you guess right, you live. If you guess wrong, you die. We move to the next person in line (the 19th) and ask the same question. This continues through all the prisoners.”
The prisoners are free to communicate through the night. Can you come up with a way to guarantee the life of some prisoners? How many?