Hi Samuel.bradley.99
The idea is not clear. Needs more explanation.
They also assign themselves with one of the numbers 0 to 4 (i.e. the 1st prisoner is assigned with number 0, the 2nd with 1 etc).
The above is pre-agreed before they wear the hats.
After they wear the hats, they do the following:
Then each prisoner calculates the sum of the numbers of the hat colors, based on the above table and DEDUCTS this number from his own and then converts the difference to mod(5). Then he finds the color that this number corresponds to, based on the above table.
Example: Suppose the 2nd prisoner sees the following hats to the other four: 1st-3rd-4th-5th: Cyan-Cyan-Red-Green. Let's assume his own hat is Yellow.
Then he calculates the sum 0+0+3+4=7. His own number is 1 (because he is the 2nd and number 1 is assigned to him). He deducts 7 from 1 and converts the difference (6) to mod(5) = 1. Then he guesses that he wears a Magenta hat. Obviously he is wrong, but let's see what the others will guess (because, even if all are wrong and ONLY one guesses correctly, they are saved).
The 1st one sees Yellow-Cyan-Red-Green and calculates the sum 9, which he deducts from his own that is 0, so the remainder is 9 which is 4 mod(5) so he guesses that he wears Green, which is also wrong because he wears Cyan.
Similarly the 3rd guesses Yellow and is wrong because he wears Cyan,
the 4th guesses Red which is CORRECT
and the 5th guesses Magenta and is wrong because he wears Green.
We therefore see that they are saved because always, at least one will guess correctly, based on the above strategy (the key here is that they are each assigned one different number of the 5 mod(5) so at least one will be correct).
Obviously no one knows the sum of all colors, since each of them does not see his own hat, but we know for sure that it will be one of the 5 numbers 0-4 mod(5).
We know, though, that it is sufficient that at least one finds the correct color, then at least one will have the number that will be the same as the correct sum of the hat colors, so he will announce the correct color!
E.g. Prisoner 1 writes x if he can see odd number of colour 1, y if he can see even number of colour 1.
Prisoner 2 does the same with colour 2, 3 with 3, 4 with 4.
Prisoner 5 can therefore ascertain what is on his head. Not sure how you do it simultaneously though
I think the prisoners are executed by now.
I think the prisoners are executed by now.
]]>If any prisoner can figure out and say to the jailer what color hat he has on his head with 100% certainty, all five prisoners go free. If any prisoner suggests an incorrect answer, all five prisoners are executed. Communication among the prisoners is allowed only before they put the hats on and is prohibited afterwards. They all write their guess on a piece of paper simultaneously, without anyone reading each other's guess.
What strategy must they follow so as to go free?