Sunday, November 16, 2014

Alternating T-Shirt Colors

This is a puzzle from Microsoft Research Page: "Ten friends walk into a room where each one of them receives a hat.  On each hat is written a real number; no two hats have the same number.  Each person can see the numbers written on his friends' hats, but cannot see his own.  The friends then go into individual rooms where they are each given the choice between a white T-shirt and a black T-shirt.  Wearing the respective T-shirts they selected, the friends gather again and are lined up in the order of their hat numbers.  The desired property is that the T-shirts colors now alternate.The friends are allowed to decide on a strategy before walking into the room with the hats, but they are not otherwise allowed to communicate with each other (except that they can see each other's hat numbers).  Design a strategy that lets the friends always end up with alternating T-shirt colors."

My solution is based on induction. 
Assume we have a numbered sequence 
1 2 3 4 5 6 7 8 ...
We may assign alternating ranks to to stand for the alternating colors for each number. 
1 0 1 0 1 0 1 0 ...

Now if we permutate 2 arbitrary numbers once with exactly the same rank, for example
1 2 7 4 5 6 3 8...

We can see any number beside the chosen 2 numbers will observe one permutation. For the 2 numbers themselves, because the chosen 2 numbers have the same rank, there were always odd number of digits between them (4, 5, 6) . Once the permutation happened, the numbers that are switched will be observing odd number of permutations. In conclusion,  the parity of the number of permutation will be preserved by an observation made by inside numbers and outside numbers alike.

Next if we permuate 2 arbitrary numbers of different ranks, for example
1 2 6 4 5 3 7 8

For an outside observer (those numbers which are not permutated), an odd number of permutation is observed, yet an even number of permutation is observed by the numbers which are permutated. We can extend this rule to multiple permutations of numbers of different ranks. In conclusion, the parity of the number of permutation will be preserved by an outsider's observation, and will be reverted by an insider's observation if its final position is in a different rank. 

Any other case can be reduced to the above 2 cases, for example
1 2 4 6 5 3 7 8 is a combination of 1 2 3  6 5 4 7 8 and then 1 2 4 6 5 3 7 8

Base on the above properties of permutations, we can conclude that the solution to the puzzle is: Each number observes the parity of the permutations. If it's odd then it switches its rank and if it's even then it retains its rank. 





No comments:

Post a Comment