彩虹帽子
Rainbow Hats
题目详情
7 名囚徒各戴 7 种颜色之一的帽子(例如彩虹七色),每人能看到其他 6 人的帽色但看不到自己的。
之后所有人同时猜自己帽色(每人说一个颜色),所有人都能听到他人猜测。
如果至少 1 人猜对,则全部获释,否则全部处死。
请给出一种策略,保证他们必然获释。
Seven prisoners each receive a hat of one of seven colors (e.g., the colors of the rainbow). They see each other’s hats but not their own, and cannot communicate once they see them. Each prisoner guesses his own hat color (all guesses heard by everyone). If at least one prisoner guesses correctly, all go free. Otherwise, all die. Devise a strategy that guarantees their freedom.
解析
把 7 种颜色编码为 (模 7)。给囚徒编号 。
设全体帽色编码之和为 。
第 个囚徒看到其他 6 人编码和为 ,则他猜自己的编码为
等价地,让囚徒 假设总和为 (模 7)并据此猜测,则恰有 的那个人猜对,从而保证至少 1 人正确。
Original Explanation
Assign each color a number 0–6 mod 7, and label prisoners 0–6. Let the sum of all hats’ “color numbers” be (mod 7). Prisoner guesses the color that makes Only the correct (namely ) will guess his hat color correctly, ensuring at least one correct guess.