To finish the Riddler question, BrunoVisnadi indeed guessed correctly on a previous post that the strategy is improvable to 7/8. This is actually a
coding theory problem in disguise:
Let 0=white, 1=black and assign an order to the 7 friends. Map each of the 2
7=128 possible hat distributions to a binary sequence of 0's and 1's of length 7, e.g. 0110101. This problem then becomes: can at least 1 of the 7 friends correctly guess the sequence given that each one sees every symbol (0 or 1) except their own?
Consider a particular sequence (say 0110101). Say we take a chance and assume that 0110101 is
not the sequence. If 0110101 is the actual sequence, then we lose. However, if 0110101 is not the sequence, but 1110101 is, then we can win; friend 1 sees ?110101 and so correctly guesses that it is 1110101. Likewise, we can correctly guess 0010101, 0100101, ..., 0110100, that is, any of the 7 sequences that are one symbol away from 0110101. So for 1 losing sequence, we can generate up to 7 winners (maximum winning rate is thus 7/8).
The strategy is thus: Choose a subset S of the 128 binary sequences, such that the number of sequences that are not in S and are one away from an element of S (and thus sure winners) is maximized. It turns out for n=7 that there is such an S (of size 128/8=16) that exactly achieves the maximum; that is, every element not in S is one away from exactly one element in S. For example:
S={0000000,1101000,0110100,0011010,0001101,1000110,0100011,1010001, 1111111,0010111,1001011,1100101,1110010,0111001,1011100,0101110}
(I.e. all 0's and 1101000 and all its cycles, and then all their complements.)
The strategy: For each friend, if one of the two possibilities is an element of S, guess the one which is
not in S; otherwise pass. The strategy wins if the sequence is not in S and loses if the sequence is in S. Win rate: 7/8.
S is what is known as a
Hamming code of 7 bits. The Hamming codes are the "optimal" solutions for the S in the strategy above; they occur whenever n=2
N-1 and the win rate is (2
N-1)/2
N. E.g. for n=3, S={000,111}; this is the "guess the other color if you see two hats of the same color and pass otherwise" strategy already described in one of the previous posts and has a win rate of 3/4.