37
$\begingroup$

This is a variant about guessing hat colors. You may want to try Hats and alien or Guessing hat colors or Four prisoners wearing black and white hats.

Statement

4 prisoners are to be executed. The warden proposed a new challenge: he will distribute four hats amongst them, chosen from two colors at most. One hat will be distributed to each prisoner and they won't be able to see their own (but they will see each other's hats).

They will have to state the color of their own hat, all at the same time. They will be released if all their answers are True or if all their answers are False.

Question

As they have one night to prepare their strategy, is there a way they can be released for sure?

EDIT: Prisoners are not aware of the colors, they can't communicate with each other after the hats are distributed. And there is no predetermined number of hats of each color (could be 0-4, 1-3 or 2-2). They also have to announce one of the one or two colors chosen by the warden, otherwise they will be executed.

$\endgroup$
  • $\begingroup$ Are lateral-thinking approaches acceptable for this puzzle? $\endgroup$ – HugoBDesigner Feb 22 '18 at 16:50
  • $\begingroup$ No. But you can post it in comments I believe. btw The warden will execute them is they say a non-color word. $\endgroup$ – Untitpoi Feb 22 '18 at 16:51
  • 2
    $\begingroup$ Just have them all shout a color that is different from the two pre-determined colors ;) $\endgroup$ – HugoBDesigner Feb 22 '18 at 16:52
  • 3
    $\begingroup$ @LeppyR64 I mean, if they all choose a particular esoteric color, like "cerulean blue" the odds of them being exactly correct go down with the size of the color space. Even better if they pick a color with RGB values. The odds of them guessing the exact color approaches 0 as the color space gets larger. $\endgroup$ – Jonathan Pullano Feb 22 '18 at 20:34
  • 12
    $\begingroup$ The real riddle is why all these wardens are offering to let prisoners go if they guess a hat color when they're convicted of crimes warranting execution. $\endgroup$ – jpmc26 Feb 22 '18 at 23:33
68
$\begingroup$

This is a bit of a stretch and I'm not sure it'd even work, but...

Each prisoner should shout the one you see the least colors of.
If all colors the same, you shout the same color you see.

For convenience, I'll use black and white to represent the two possible different colors.
If the distribution is 2 whites and 2 blacks the prisoner sees 2 of one color and 1 of the other. The prisoner will always be right by this approach.
If the distribution is 3 whites and 1 black, the white ones will have all been wrong. If you're the 1 black in that scenario, you'll be wrong too.
Last but not least, if all are the same color, all will be right.

$\endgroup$
  • 3
    $\begingroup$ I don't think the prisoners know in advance what the two potential colours are, so your prisoner could see three purple hats. $\endgroup$ – c.. Feb 22 '18 at 20:20
  • 14
    $\begingroup$ Yes, and that prisoner would say "purple". I used "black and white" to make the explaining easier, but it really works with any color presented by the warden. $\endgroup$ – HugoBDesigner Feb 22 '18 at 20:22
  • 1
    $\begingroup$ So simple and so effective! $\endgroup$ – Lawrence Feb 23 '18 at 1:19
  • 1
    $\begingroup$ @HugoBDesigner I obviously did not spend enough time thinking about this, well done $\endgroup$ – c.. Feb 23 '18 at 3:00
  • 2
    $\begingroup$ @TonyEnnis The puzzle requires the prisoner to shout a color that exists in a hat. If there are two colors - say, black and white - but the prisoner can only see one of them, they're left at guesswork for the second color. Therefore, chances are they're shout a color that isn't in hats, thus failing the puzzle. $\endgroup$ – HugoBDesigner Feb 24 '18 at 3:45
23
$\begingroup$

A simple way would be that

each prisoner guesses that there’s an even number of each colour.

Either there is, or there isn’t, but since everybody guessed the same, everyone will be right, or everybody will be wrong. No-one can be wrong by more than one, so whenever the guesses are a different number, the correct number is guaranteed to be the number in between.

EDIT: On closer inspection, this seems to be exactly what’s happening in @HugoBDesigner’s answer. Well, at least this explains why it works.

RE-EDIT: This approach turns out to be quite nice, since it generalises handily to N prisoners (decide in advance, which colour’s parity you are going to count), and it also points to the other solution:

Everybody can guess ”odd number of each colour”.
- if you see an odd number of ”white” hats, guess ”black”.
- if you see an even number of ”white” hats, guess ”white”.

(substitute the appropriate colours for the above technique.)

$\endgroup$
  • $\begingroup$ Oh, that's much more elegant and it shows a connection with the answer to a similar puzzle. $\endgroup$ – Detached Laconian Feb 23 '18 at 1:52
  • $\begingroup$ If a prisonner see three black, He cant know the second color. Your solution can work if you say the odd color. Not the even. Speaking if generalisation, i think it only works with an even number of hats. $\endgroup$ – Untitpoi Feb 23 '18 at 6:39
  • $\begingroup$ @Untitpoi I think you have that the wrong way around. If the prisoner sees three black hats and guesses there's an even number of each colour, the prisoner would say "black" without needing to know of any other colour. If the prisoner sees three black hats and guesses there's an odd number of each colour, that's when it won't work. $\endgroup$ – hvd Feb 23 '18 at 6:48
  • 1
    $\begingroup$ @Untitpoi, if the warden insists that ”the colour that is not black” is not an adequate answer, and won’t tell the coulours in advance (and he might, totally erratic as he is), then there will be extra complications, and ”guess the odd colour” is the only working strategy. $\endgroup$ – Bass Feb 23 '18 at 7:14
  • 3
    $\begingroup$ It looks like there may be a problem with odd N, if the warden at no point divulges the colours’ names. $\endgroup$ – Bass Feb 23 '18 at 11:58
3
$\begingroup$

My answer is similar to that of HugoB's but I think my reasoning adds something new to the solution. I was stuck turning it over and over in my head until I realised a key on how to start.

I start simply by realising that in the case of a 3-1 split happening, the person who sees three colours can only guess the colour he sees because he does not know what the second colour is.

Therefore,

to be assured of a certain escape, he must avoid any chance of failure (by chancing a non-existent colour) and he must guess the colour he sees.

Then,

you reason through what the other prisoners must say in order to match the "wrongness" or "rightness" of the person who only sees three and you come up with saying the lesser colour.

If, however,

there is a 2-2 case, the reasoning merely changes for the person who saw 3 same colours; he now sees two and guesses the lesser. If there is a 4-0 case, it is similar to the 3-1 because now everyone can only guess one colour because they only see one colour. Merely the "rightness" or "wrongness" changes.

$\endgroup$
2
$\begingroup$

All prisoners state

a colour that is indistinguishable on the human visible spectrum.

Examples of these colours can be red-green or blue-yellow, or (depending on the warden's definition of colour) ultra-violet or infra-red.

Due to the colours mentioned not being perceptible, the actual colour of their hats will appear to a human as a regular colour (the correct answer of their hats), ensuring that the prisoners are always giving a false answer, resulting in their freedom.

$\endgroup$
  • 2
    $\begingroup$ A color is by definition visible. $\endgroup$ – jpmc26 Feb 23 '18 at 3:33
  • $\begingroup$ I like the answer... jpmc26, if we say a color must be visible, but it needn't be visible to a given observer. For instance if a fully color-blind person is looking at something, does it cease to have color? If a bee is looking at it but a human is too, does the bee stop perceiving that color? $\endgroup$ – Swiss Frank Feb 23 '18 at 9:07
  • 1
    $\begingroup$ @SwissFrank Assuming red-green color-blindness (for example), red and green are both visible to the color-blind person. They just aren't distinguishable. $\endgroup$ – Ray Feb 23 '18 at 23:03
1
$\begingroup$

Assuming they are all either perfectly logical, or they were able to discuss a strategy before hand... The answer is;

They all say the color they see less of... Unless they don't see any of one color. Then they say the color they see. (if I see 3 whites I say white, if I see 3 blacks I say black.)

If it is an even 2-2 split;

Both whites see 2 blacks 1 white and say white, likewise black does the inverse.

if it is a 3-1 split;

Lets say that there are 1 white 3 blacks. White sees no white so they say black, each black sees 1 white and 2 blacks, they each say white, thus they are all wrong and win.

if it is a 4-0 split;

Lets say they are all white, they all see 3 whites and no black so they all say white. thus they are all right and win.

$\endgroup$
  • 3
    $\begingroup$ How does your answer add to the identical one already given? You should always look at existing answers before providing one of your own, to ensure you are not just adding a duplicate. $\endgroup$ – Rubio Feb 22 '18 at 22:36
  • $\begingroup$ when I answered this it was unclear if he had figured all of it out, because it hadn't been edited yet. $\endgroup$ – Sam Harrington Feb 23 '18 at 1:38
-1
$\begingroup$

They all shout the same RGB hex-code, using 16 bits per channel, e.g. BBBB BBBB BBBB. The odds that they're all wrong is almost 100%. It's not exactly 100%, but it's certainly way closer than HugoBDesigner's answer. Of course you could use even more bits, but I'll just assume that at some point it won't matter to the warden, because the colors can't be distinguished by the human eye any further.

$\endgroup$
  • 1
    $\begingroup$ If you can assign the colors based on real numbered RGB values (say between 0.0 and 1.0), the odds are actually 100% (i.e. they are "almost surely" correct. See: en.wikipedia.org/wiki/Almost_surely). Though in practice this might not work because I think light frequencies are quantized. $\endgroup$ – Jonathan Pullano Feb 23 '18 at 19:54
  • $\begingroup$ The puzzle doesn't specify how the warden decides what color hats to use, so I don't think you can assume anything meaningful about probability. He could defeat this strategy by listening in on the prisoners' conversation and then using the color they agree to name. $\endgroup$ – Micah Feb 24 '18 at 14:55
  • $\begingroup$ There are ways around people listening in and even ways around filming and such. They're thieves so they of all people would know about secret codes and whatnot. But note that the point is moot, because the OP has edited the question so that the thieves must all name one of the up to two colors that were used by the warden. So now the warden just distributes transparent hats and then kills them all. :-) $\endgroup$ – Alex Feb 27 '18 at 12:58
-1
$\begingroup$

The funny thing is that while this puzzle seems not to offer enough info to solve at first glance, it's suprisingly amenable to

brute force.

If we merely make the observations that 1) it is symmetric and 2) the answer has to be based on how many hats of the majority color you see, then it boils down to:

1) what do you say if the majority is three hats?
2) what do you say if the majority is two hats?

(Choices of one and zero are eliminated by the definition of majority.)

And further... since you have to name an existing color, in question 1 you have to guess the majority color.

So the brute force analysis has only two cases to crank through--two possible answers for question 2--one of which clearly fails.

$\endgroup$
  • $\begingroup$ This approach is roughly identical to Sam Harrington's answer, which itself is already a more complicated version of the accepted answer... $\endgroup$ – votbear Mar 1 '18 at 8:53
  • $\begingroup$ The spoiler markup doesn't seem to be working on this answer and I have no idea why. $\endgroup$ – F1Krazy Mar 1 '18 at 8:58
  • 1
    $\begingroup$ @F1Krazy check my edit. You need to add extra spaces at the end of the line. It's kinda crazy but it does the job. $\endgroup$ – Glorfindel Mar 1 '18 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.