Return to Video

Can you solve the prisoner hat riddle? - Alex Gendler

  • 0:11 - 0:14
    You and nine other individuals
    have been captured
  • 0:14 - 0:17
    by super intelligent alien overlords.
  • 0:17 - 0:21
    The aliens think humans look quite tasty,
  • 0:21 - 0:26
    but their civilization forbids eating
    highly logical and cooperative beings.
  • 0:26 - 0:30
    Unfortunately, they're not sure
    whether you qualify,
  • 0:30 - 0:33
    so they decide to give you all a test.
  • 0:33 - 0:34
    Through its universal translator,
  • 0:34 - 0:38
    the alien guarding you
    tells you the following:
  • 0:38 - 0:43
    You will be placed in a single-file line
    facing forward in size order
  • 0:43 - 0:47
    so that each of you can see
    everyone lined up ahead of you.
  • 0:47 - 0:51
    You will not be able to look behind you
    or step out of line.
  • 0:51 - 0:55
    Each of you will have either a black
    or a white hat on your head
  • 0:55 - 0:57
    assigned randomly,
  • 0:57 - 1:01
    and I won't tell you
    how many of each color there are.
  • 1:01 - 1:05
    When I say to begin, each of you must
    guess the color of your hat
  • 1:05 - 1:09
    starting with the person in the back
    and moving up the line.
  • 1:09 - 1:13
    And don't even try saying words
    other than black or white
  • 1:13 - 1:17
    or signaling some other way,
    like intonation or volume;
  • 1:17 - 1:20
    you'll all be eaten immediately.
  • 1:20 - 1:24
    If at least nine of you guess correctly,
    you'll all be spared.
  • 1:24 - 1:27
    You have five minutes to discuss
    and come up with a plan,
  • 1:27 - 1:32
    and then I'll line you up,
    assign your hats, and we'll begin.
  • 1:32 - 1:36
    Can you think of a strategy guaranteed
    to save everyone?
  • 1:36 - 1:39
    Pause the video now
    to figure it out for yourself.
  • 1:39 - 1:40
    Answer in: 3
  • 1:40 - 1:41
    Answer in: 2
  • 1:41 - 1:43
    Answer in: 1
  • 1:43 - 1:46
    The key is that the person
    at the back of the line
  • 1:46 - 1:50
    who can see everyone else's hats
    can use the words "black" or "white"
  • 1:50 - 1:54
    to communicate some coded information.
  • 1:54 - 1:57
    So what meaning can be
    assigned to those words
  • 1:57 - 2:01
    that will allow everyone else
    to deduce their hat colors?
  • 2:01 - 2:04
    It can't be the total number
    of black or white hats.
  • 2:04 - 2:07
    There are more than two possible values,
  • 2:07 - 2:12
    but what does have two possible values
    is that number's parity,
  • 2:12 - 2:15
    that is whether it's odd or even.
  • 2:15 - 2:19
    So the solution is to agree
    that whoever goes first will,
  • 2:19 - 2:23
    for example, say "black" if he sees
    an odd number of black hats
  • 2:23 - 2:28
    and "white" if he sees
    an even number of black hats.
  • 2:28 - 2:32
    Let's see how it would play out
    if the hats were distributed like this.
  • 2:32 - 2:35
    The tallest captive sees three black
    hats in front of him,
  • 2:35 - 2:41
    so he says "black," telling everyone else
    he sees an odd number of black hats.
  • 2:41 - 2:44
    He gets his own hat color wrong,
    but that's okay
  • 2:44 - 2:48
    since you're collectively allowed
    to have one wrong answer.
  • 2:48 - 2:51
    Prisoner two also sees an odd
    number of black hats,
  • 2:51 - 2:55
    so she knows hers is white,
    and answers correctly.
  • 2:55 - 2:58
    Prisoner three sees
    an even number of black hats,
  • 2:58 - 3:01
    so he knows that his must be
    one of the black hats
  • 3:01 - 3:04
    the first two prisoners saw.
  • 3:04 - 3:05
    Prisoner four hears that and knows
  • 3:05 - 3:09
    that she should be looking for
    an even number of black hats
  • 3:09 - 3:11
    since one was behind her.
  • 3:11 - 3:16
    But she only sees one, so she deduces
    that her hat is also black.
  • 3:16 - 3:20
    Prisoners five through nine are each
    looking for an odd number of black hats,
  • 3:20 - 3:25
    which they see, so they figure out
    that their hats are white.
  • 3:25 - 3:29
    Now it all comes down to you
    at the front of the line.
  • 3:29 - 3:32
    If the ninth prisoner saw
    an odd number of black hats,
  • 3:32 - 3:35
    that can only mean one thing.
  • 3:35 - 3:39
    You'll find that this strategy works
    for any possible arrangement of the hats.
  • 3:39 - 3:45
    The first prisoner has a 50% chance of
    giving a wrong answer about his own hat,
  • 3:45 - 3:47
    but the parity information he conveys
  • 3:47 - 3:52
    allows everyone else
    to guess theirs with absolute certainty.
  • 3:52 - 3:56
    Each begins by expecting to see an odd
    or even number of hats
  • 3:56 - 3:58
    of the specified color.
  • 3:58 - 4:03
    If what they count doesn't match,
    that means their own hat is that color.
  • 4:03 - 4:04
    And everytime this happens,
  • 4:04 - 4:09
    the next person in line will switch
    the parity they expect to see.
  • 4:09 - 4:11
    So that's it, you're free to go.
  • 4:11 - 4:13
    It looks like these aliens
    will have to go hungry,
  • 4:13 - 4:16
    or find some less logical
    organisms to abduct.
Title:
Can you solve the prisoner hat riddle? - Alex Gendler
Speaker:
Alex Gendler
Description:

View full lesson: http://ed.ted.com/lessons/can-you-solve-the-prisoner-hat-riddle-alex-gendler

You and nine other individuals have been captured by super-intelligent alien overlords. The aliens think humans look quite tasty, but their civilization forbids eating highly logical and cooperative beings. Unfortunately, they’re not sure whether you qualify, so they decide to give you all a test. Can you solve this hat riddle? Alex Gendler shows how.

Lesson by Alex Gendler, animation by Artrake Studio.

more » « less
Video Language:
English
Team:
closed TED
Project:
TED-Ed
Duration:
04:35

English subtitles

Revisions Compare revisions