Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise 5. The same warden has a different idea. He orders the prisoners to sta

ID: 3745694 • Letter: E

Question

Exercise 5. The same warden has a different idea. He orders the prisoners to stand in line, and places red and blue hats on each of their heads. No prisoner knows the color of his own hat, or the color of any hat behind him, but he can see the hats of the prisoners in front. The warden starts at the back of the line and asks each prisoner to guess the color of his own hat. The prisoner can answer only “red” or “blue.” If he gives the wrong answer, he is fed to the crocodiles. If he answers correctly, he is freed. Each prisoner can hear the answer of the prisoners behind him, but cannot tell whether that prisoner was correct. The prisoners are allowed to consult and agree on a strategy beforehand (while the warden listens in) but after being lined up, they cannot communicate any other way besides their answer of “red” or “blue.” Devise a strategy that allows at least P 1 of P prisoners to be freed

Explanation / Answer

-------------------------------------------
Considering below assumptions:

Total Number of Prisoners : P
Total Number of Red Hats = Total Number of Blue Hats

All Prisoners need to gather before line need to built below strategy to get at least P-1 freed.

Last Prisoner need to count total number of Blue hats and Red hats in front of him. Need to check which hat has less count(
Means out of P hats, if P/2 hats are and (P-1)/2 hats are blue) prisoner need to says less count hats.
This Strategy need to follow all by all prisoner. It helps all prisoners to get freed.