1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Challenge 9: The Prisoner Line-Up

  1. Dec 2, 2013 #1


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Countably infinite prisoners, numbered 1,2,3 etc. are told that tomorrow they will be given hats, colored either black or white, and lined up so that each prisoner can only see the prisoners whose hats are labeled with a greater number. The prisoners then get to guess which color hat they wear, in order from 1 onwards. If all but finitely many of them guess which color hat they have, the prisoners win and they are let free.

    The challenge: Describe a strategy which lets the prisoners go free. Assume as with all such challenges that the prisoners can't communicate in secret once they get their hats, they can see infinitely far to all the prisoners that are supposed to be visible to them, they have perfect memory and are perfectly logical and all those other things that people can't do in real life.

    Bonus points if you can create a strategy that places a specific upper bound on how many prisoners get their hat wrong.
  2. jcsd
  3. Dec 2, 2013 #2
    Let's assume a (somehow stronger) version of choice, say the axiom of collective choice, that for any set [itex]\mathcal X[/itex] of sets, the prisoners can agree on an element of [itex]\prod_{X\in\mathcal X} X[/itex]. Hopefully that's not cheating.

    Define a binary relation on [itex]Z= \{b,w\}^\infty[/itex] via [tex]\sim := \{(x,y)\in Z\times Z: \enspace x,y \text{ agree on cofinitely many entries} \}[/tex] which is easily seen to be an equivalence relation. By collective choice, the prisoners can agree on a function [itex]f: Z\to Z[/itex] such that
    - Every [itex]z\in Z[/itex] satisfies [itex]f(z)\sim z[/itex].
    - Every [itex]z,y\in Z[/itex] with [itex]z\sim y[/itex] satisfy [itex]f(z)=f(y)[/itex].

    The guessing rule: If [itex]z[/itex] is the true hat sequence, prisoner [itex]k[/itex] guesses [itex]f(z)_k[/itex], which he knows, because he knows the [itex]\sim[/itex]-class of [itex]z[/itex].

    Because [itex]f(z)\sim z[/itex], only finitely many of the prisoners can be incorrect.
  4. Dec 2, 2013 #3


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    economicsnerd, your axiom of collective choice is just the axiom of choice plus one prisoner telling everyone what he chose so I'll allow it. That's a really nice solution. Any alternate or stronger solutions out there? (by stronger I mean limiting how many prisoners guess wrong).
  5. Dec 2, 2013 #4
    True. I guess I was just worrying about being able to "tell" something with so much information in it.
  6. Dec 2, 2013 #5
    Define the real number [itex]a[/itex] to be the number (between 0 and 1) whose binary expansion is represented by the sequence of hat colors (white = 0, black = 1). Assuming this is a computable number, then there exists an algorithm to compute it with arbitrary precision. This algorithm must be finite, so it can be encoded in a binary program of length n. The first n prisoners will say each bit in the program (using the convention that white = 0 and black = 1). Then all other prisoners will be able to run the algorithm in their heads up to the desired accuracy to predict their own hat color.

    I see a few flaws in this solution, for example not all numbers are computable (but for all purposes, who could realistically generate such a number in the first place? :P ). Also, I am not sure whether it is possible to generate an algorithm to compute a computable number given only its decimal (binary) expansion. This would work well for rational numbers, or even algebraic numbers (by encoding the coefficients of the polynomial whose root we are looking for, and then using numerical methods such as Newton-Raphson, etc).

    EDIT: speaking of that, I think there's something wrong or that I have misunderstood. The set of all sequences of ones and zeros is uncountable. But if there was a strategy that gave a finite upper bound N on the number of prisoners who must guess, then the set of all possible sequences generated by such a strategy must be countable, since it depends only on N bits, and so only 2^N such sequences are possible. Thus some sequences would not be described by such a strategy.
    Last edited: Dec 2, 2013
  7. Dec 3, 2013 #6
    As a matter of fact, it's possible for us to construct a strategy that guarantees that at most one prisoner will get his hat wrong. As in economicsnerd's solution, we start by having the prisoners agree on a choice function [itex]f[/itex] on the set of all infinite sequences. The first prisoner counts the number of positions [itex]k\geq 2[/itex] such that [itex]f(z)_k \neq z_k[/itex] - which will necessarily be a finite number - and then calls out "black" if this number is even and "white" if this number is odd. The second prisoner observes the number of [itex]k\geq 3[/itex] such that [itex]f(z)_k \neq z_k[/itex], and by comparing the parity he gets with that indicated by the first prisoner, determine whether [itex]f(z)_2 = z_2[/itex] and hence the color of his own hat, which he calls out. This gives the third prisoner enough information to deduce and call out the color of his hat, followed by the fourth, and so on. Hence every prisoner except possibly the first will correctly guess the color of his own hat with this strategy.
  8. Dec 3, 2013 #7


    User Avatar
    2017 Award

    Staff: Mentor

    @Boorglar: The set of computable numbers is countable, so this strategy does not cover most cases.

    With at most N guesses, you can distinguish more than 2^N cases - there is some freedom which prisoners decide to transmit information (instead of trying to get their own hat right based on the previous information). Doesn't change much, however.

    Is this possible without the axiom of choice? If not, I think Citan Uzuki found the perfect solution.
  9. Dec 3, 2013 #8
    Yeah I just realized another (huge) flaw in my answer: the first prisonner might think of a number and come up with an algorithm. But the second prisoner will not see the same number, and he has no way to know which algorithm the 1st prisoner had in mind.

    And also, mfb is right. The information that prisoner n obtains contains the hat colors for prisonners 1 to n-1. So each prisoner actually has more information than the previous.
  10. Dec 3, 2013 #9
    Agreed! It's a very elegant solution.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook