Skip to content
Vamshi Jandhyala

Books · The Fiddler: Solutions

Chapter 3

Can You Infer the Color of Your Hat?

Three game-show contestants must work together. They are shown a bag into which three red hats and two white hats are placed. Each contestant, blindfolded, draws a hat and puts it on; two hats remain in the bag. The blindfolds are then removed one at a time. Each contestant can see the others’ hats but not their own, and can hear every earlier decision. On your turn you either name your hat’s color, but only if you are certain, or you pass. The group wins if anyone ever names their color correctly. Will they always win?

The Fiddler, Zach Wissner-Gross, June 5, 2026(original post)

Solution

Yes, they always win, and the reason is that a pass is itself information. Reveal the contestants in a fixed order, each naming their color the instant they are sure and otherwise passing.

The one immediate certainty: seeing two white hats forces your own to be red, since only two whites exist. So a pass announces “I do not see two whites.” If two whites are worn, the lone red-wearer wins at once. Otherwise the first passes; the second, hearing that the last two are not both white, names red if it sees the third in white, and otherwise passes, revealing the third is red, who then names it. Either way someone is correct: they always win.\boxed{\text{they always win.}}

The computation

Run the deduction as possible-worlds elimination: start from every consistent hat assignment, and on each contestant’s turn either declare (when every surviving world that matches what they see agrees on their own colour) or prune the worlds their pass rules out. Check that a correct call always arises, for every true assignment.

import itertools
from collections import Counter
def always_win(avail, n):           # avail: Counter of hats; n contestants
    cols = sorted(avail)
    worlds = {w for w in itertools.product(cols, repeat=n)
              if all(v <= avail[k] for k, v in Counter(w).items())}
    def wins(true):
        poss = set(worlds)
        for _ in range(n + 1):
            for i in range(n):
                seen = [w for w in poss if all(w[j] == true[j]
                        for j in range(n) if j != i)]
                if len({w[i] for w in seen}) == 1:      # i is certain
                    return True
                poss = {w for w in poss if len({x[i] for x in poss
                        if all(x[j] == w[j] for j in range(n) if j != i)}) > 1}
                poss = poss or {true}
        return False
    return all(wins(w) for w in worlds)
print(always_win(Counter({'R': 3, 'W': 2}), 3))   # True

Extra Credit

Now four contestants play, and the bag is filled with RR red, WW white, and BB blue hats, each count at most 44. The rules are unchanged. For which triples (R,W,B)(R,W,B) can the group always win, and among those, what is the greatest value of R+W+BR+W+B?

Solution

The same engine settles it. Running the deduction for every distribution with each count at most 44 (and at least four hats to draw), the group is guaranteed to win for 6363 of the triples, and the largest total among them is R+W+B=7.R + W + B = \boxed{7}. The maximum is reached by twelve arrangements, such as (4,3,0)(4,3,0), (1,2,4)(1,2,4), and (4,1,2)(4,1,2): the deduction survives only while the hats are scarce enough that each turn, what a contestant sees plus the earlier passes pins down their own hat. (The source’s answer is behind its paywall; this is my own.)

The computation

Sweep every (R,W,B)(R,W,B) with each count at most 44 and at least four hats total, run the same always_win deduction for four contestants, and collect the winning distributions and their largest total.

best, winners = 0, []
for R in range(5):
    for W in range(5):
        for B in range(5):
            if R + W + B < 4: continue
            if always_win(Counter({'R': R, 'W': W, 'B': B}), 4):
                winners.append((R, W, B)); best = max(best, R + W + B)
print(len(winners), best)            # 63 7