The key is that the person at the back of the line who can see everyone else's hats
其实重点在于排在队尾的人,他在看到其他所有人的帽子后
can use the words "black" or "white" to communicate some coded information.
可以用黑白来传递加密信息。
So what meaning can be assigned to those words that will allow everyone else to deduce their hat colors?
那么我们应当在这些词上附加什么含义,以使得其他人可以推测他们帽子的颜色呢?
It can't be the total number of black or white hats.
首先不能是黑帽子或白帽子的总数。
There are more than two possible values,
那样可能的值就会超过两种。
but what does have two possible values is that number's parity, that is whether it's odd or even.
但是数字的奇偶性恰好只有两种可能,那就是奇数或偶数。
So the solution is to agree that whoever goes first will, for example,
所以,解决方案就在于第一个说的人,举个例子,
say "black" if he sees an odd number of black hats and "white" if he sees an even number of black hats.
比如他看到了奇数个黑帽子,他就要说“黑色”,当他看到了偶数个黑帽子时就要说“白色”。
Let's see how it would play out if the hats were distributed like this.
我们看下如果帽子颜色是这样分配的话,这个策略执行起来如何。
The tallest captive sees three black hats in front of him,
最高的人看到前面有三个黑帽子,
so he says "black," telling everyone else he sees an odd number of black hats.
所以他说“黑色”,告诉其他所有人他看到的是奇数个黑帽子。
He gets his own hat color wrong, but that's okay since you're collectively allowed to have one wrong answer.
他没有说对自己帽子的颜色,但是没关系,因为所有被抓的人总共可以犯一个错误。
Prisoner two also sees an odd number of black hats, so she knows hers is white, and answers correctly.
第二高的人也看到奇数个黑帽子,她就会知道她的是白色的,就答对了。
Prisoner three sees an even number of black hats,
第三个人看到前面是偶数个黑帽子,
so he knows that his must be one of the black hats the first two prisoners saw.
所以他知道他的一定是前面两个人看到的其中一顶黑帽子。
Prisoner four hears that and knows that she should be looking for an even number of black hats since one was behind her.
第四个人听到后就知道她应当看到前面有偶数顶黑帽子,因为其中一顶在她身后。