Yoak: Answer on GC: Another Buncha Prisoners

We said during the most recent podcast that we’d offer the answer to the ending puzzle on the website.

Twitter user @snoble posted a hint on #mathfactor that points to the right answer.

First, I’ll review the problem.  You and nine other prisoners will be lined up in the morning front to back.  Each of you will have either a blue or red hat placed upon your head.  Each person can see all the hats on the heads of people in front of him, but not the color of his own or of any of the people behind.

The guards will then proceed to the rear of the line and ask that person the color of the hat on his own head.  He must guess and if he guesses wrong, sadly, he’ll be shot.  Either way, the guard then proceeds to the number nine position and repeats through all of the other prisoners.

Knowing that this will happen and with a night to plan, what strategy can the prisoners develop to maximize their expected survival rate?

[spoiler]During the show, I suggested a 75% solution and claimed that you can do much better.  In fact, 95% of the prisoners should survive.  Here’s how it is done.

The person in the rear of the line announces the “red” if he sees an even number of red hats in front of him and “blue” if the number is odd.  He’ll be right about his own hat 50% of the time.  There’s no help for that as he has no information at all.  But from this, all future prisoners know with certainty the color of their own hat!  Here’s how:

If the person in the rear says “red,” number nine knows that he saw an even number of red hats.  If he also sees an even number of red hats, he knows that his own hat must be blue.  Likewise, if he sees an odd number of hats, the only way for ten to have seen an even number of red hats is if his own hat is read.

By keeping track of each answer and the change between even / odd indicated by the answers, each person can correctly guess the color of his own hat for a total of 95% success.

Interestingly, this works even if the guards know what the prisoners are up to.  Unlike the hat problem in GB where the hat placers can make failure 100% likely knowing the strategy by cheating and placing hats of all the same colors on the heads of the players, in this setup, the strategy works not only on random placement but also on malicious placement.

The hint offered on twitter was to think about “parity.”  When hiring computer programmers I would sometimes offer this as an interview questions and often the people who got it would answer me with this one word and we’d move on.  It refers to parity bits in some communication protocols on computers.  When you send information over the wire, the signal may occasionally be distorted.  Parity bits are an approach to self-correction.  Suppose you send through a block of 1024 bits, 1’s and 0’s.  Suppose that you use 1023 for data and in the last bit, called a parity bit, you send 1 of the there are an even number of 1’s in the other bits, and 0 otherwise.  The receiving party can then check to make sure that this works out.  If a bit got flipped, you can request re-transmission of that block.  Of course, two errors might give you a false positive here, but if you know about how often errors occur, you can choose the size of the block you send such that errors occur as rarely as you like (with an increased cost of transmission because of parity bits.)


1 Comment »

  1. strauss said,

    August 1, 2009 at 8:23 am

    Thanks Jeff– It’s nice to see someone posts answers we promise on the podcast (unlike some people I know…)

RSS feed for comments on this post · TrackBack URL

Leave a Comment

You must be logged in to post a comment.

The Math Factor Podcast Website

Quality Math Talk Since 2004, on the web and on KUAF 91.3 FM

A production of the University of Arkansas, Fayetteville, Ark USA

Download a great math factor poster to print and share!

Got an idea? Want to do a guest post? Tell us about it!

Heya! Do us a favor and link here from your site!