Solution

Seven Hats, One Strategy

Show the problem again

Seven players agree on a strategy, after which each receives a hat that is red or blue, chosen independently by a fair coin. Each player sees the six other hats but not their own, and no communication is allowed once the hats are on. Simultaneously and silently, each player either guesses their own colour or passes. The team wins if at least one player guesses and every guessing player is correct. What is the largest probability of winning over all strategies? Give a reduced fraction.

Worked solution

The answer is 7/8. Number the players 1 to 7 and write each position as a 3-bit binary number. Treat a colouring as a 7-bit word (blue = 1) and call it good if the XOR of the positions of all blue hats is 0. Exactly 16 of the 128 words are good (they form the Hamming code), and every other word becomes good by flipping exactly one hat. Strategy: each player imagines both possibilities for their own hat. If exactly one of the two makes the word good, they guess the other colour (that is, they bet that the word is not good); if neither does, they pass. If the actual word is good (16 of 128 cases), every player sees that their actual hat completes a good word, so every player guesses the opposite colour and is wrong: the team loses. If the word is not good, exactly one hat must be flipped to repair it, so exactly one player has a good alternative; that player guesses and is right, and everyone else passes: the team wins. That is 112 wins in 128 cases, or 7/8 (confirmed by exhaustive enumeration). For optimality, a guess is right in exactly half of the colourings consistent with the guesser's view, so over all 128 colourings the total number of correct guesses equals the total number of wrong ones. Each winning colouring contributes at least one correct guess and no wrong ones, and each losing colouring contains at most seven wrong guesses. Hence W ≤ 7L, which with W + L = 128 forces W ≤ 112.

Source: Well-known hat-guessing puzzle whose optimal strategy comes from the Hamming code; folklore in the recreational-mathematics literature. Statement written for AxiomIQ.