General Question

LostInParadise's avatar

Can you figure out my variation on a colored hat problem?

Asked by LostInParadise (32183points) February 18th, 2012

There are a number of logic problems involving people wearing black or white hats, with the object being for the person to guess the color of his own hat. I came up with a variation on one of these problems using three hat colors instead of two.

I will first present the original problem and its solution. My variation will be to simply change the number of hat colors from two to three.

A group of prisoners is told that they will be given a test that will allow them to go free if they pass it. The prisoners will be seated one in front of the other, so that each can only see the people in front of him. Each prisoner will have a black or white hat placed on his head. Starting with the prisoner in the back and moving forward, each prisoner will be asked the color of his hat. If he guesses correctly, he will be allowed to go free.

Before the test, the prisoners are permitted to meet together to work out a strategy. It is agreed that the first person to be questioned has no way of knowing his hat color, so his answer will be a code that can be used by the other prisoners to guess his hat color. You can stop reading at this point if you want to solve this problem on your own.

The solution is to have the prisoner in the back give one color, say black, if the number of black hats he sees is even, and the other color if the number he sees is odd. The next prisoner will be able to tell his own hat color by checking to see if the oddness/evenness has changed. If it has changed, his hat is black, otherwise white. Each other prisoner updates the parity of hat color based on previous answers and can then figure out his own hat color.

My variation on this is the same as the first problem, except that there are three hat colors: red, yellow and blue. What strategy can they work out so that the first prisoner questioned uses a code that will allow the others to guess his hat color? My solution makes use of modular arithmetic, sometimes called clock arithmetic.

Observing members: 0 Composing members: 0

2 Answers

6rant6's avatar

red = 0, yellow = 1, blue =2. The prisoner in the back adds up the hats in front of him and gives the answer (mod 3). They need to be a little better at mental math, but the idea is the same.

LostInParadise's avatar

It is necessary to do something that distinguishes the colors. If you compute 2*blues + yellows mod 3 (or, equivalently yellows – blues mod 3), then the number will decrease by 2 if the hat is blue, by one if it is yellow and stay the same if it is red. This is really a generalization of the original problem, which is equivalent to taking the number of blacks mod 2. This can be extended to any number of colors, though the prisoners would probably need a calculator.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther