🧮 Brain Teaser

The Coin That Remembers Its Past

You flip a fair coin repeatedly. At each step, you record whether the flip matches the previous flip (call it a "match") or differs (a "change").

Question: Starting fresh (no previous flip), after nn flips, what is the probability that you have seen an even number of changes? (Count 0 as even.)

For concreteness: if the sequence is H H T H, the changes occur at positions 3 and 4, giving 2 changes — even.

Surprisingly, the answer is not 12\frac{1}{2}. Find the exact probability.

parityrandom walkcoin flippingtelescopingelegant reduction

Answer: The Coin That Remembers Its Past

Key Idea / Intuition

The parity of the number of changes after nn flips depends only on whether the last coin equals the first coin — because each "change" flips the running parity, and the sequence of changes is just a record of when the coin differs from its predecessor. So instead of tracking the full sequence, track a single bit: does the current coin match the first? This turns the problem into a simple random walk on {0,1}\{0,1\}, and the answer pops out cleanly.


Formal Proof / Solution

Setup. Label the flips X1,X2,,Xn{H,T}X_1, X_2, \ldots, X_n \in \{H, T\}. Define Ci=1[XiXi1]C_i = \mathbf{1}[X_i \neq X_{i-1}] for i=2,,ni = 2, \ldots, n. We want

P ⁣(i=2nCi0(mod2)).P\!\left(\sum_{i=2}^n C_i \equiv 0 \pmod{2}\right).

Key observation. The parity of the total number of changes equals the parity of X1XnX_1 \oplus X_n (XOR), because each change flips the running "have we switched from the original value?" bit. More precisely:

i=2nCiX1Xn(mod2)\sum_{i=2}^n C_i \equiv X_1 \oplus X_n \pmod{2}

(where we encode H=0,T=1H=0, T=1). This is a telescoping: each change toggles the value, and the cumulative parity of toggles is just whether the final value differs from the initial value.

Reduction. So we need:

P(X1=Xn).P(X_1 = X_n).

Computing P(X1=Xn)P(X_1 = X_n). Since the coin is fair, by symmetry XnX_n is uniform on {H,T}\{H, T\} regardless of nn. But we need the joint distribution of (X1,Xn)(X_1, X_n).

Let pn=P(Xn=X1)p_n = P(X_n = X_1) (they match). Conditioning on Xn1X_{n-1}:

pn=P(Xn=X1)=P(Xn=Xn1)P(Xn1=X1)+P(XnXn1)P(Xn1X1).p_n = P(X_n = X_1) = P(X_n = X_{n-1}) \cdot P(X_{n-1} = X_1) + P(X_n \neq X_{n-1}) \cdot P(X_{n-1} \neq X_1).

Since the coin is fair, P(Xn=Xn1)=12P(X_n = X_{n-1}) = \tfrac{1}{2} always. So:

pn=12pn1+12(1pn1)=12.p_n = \tfrac{1}{2} \cdot p_{n-1} + \tfrac{1}{2} \cdot (1 - p_{n-1}) = \tfrac{1}{2}.

Wait — this gives pn=12p_n = \frac{1}{2} for all n2n \geq 2, with p1=1p_1 = 1.

Answer.

P(even number of changes after n flips)={1n=112n2P(\text{even number of changes after } n \text{ flips}) = \begin{cases} 1 & n = 1 \\ \dfrac{1}{2} & n \geq 2 \end{cases}

The surprise revealed. For n2n \geq 2, the answer is exactly 12\frac{1}{2} — but the reason is subtle. It's not obvious from the raw definition, yet the telescoping XOR argument makes it crisp. The "memory" of the sequence collapses entirely into a single coin flip: does the last coin match the first?

Sanity check for n=2n=2: Only one potential change. P(no change)=P(X2=X1)=12P(\text{no change}) = P(X_2 = X_1) = \frac{1}{2}. ✓

Sanity check for n=3n=3: Two potential changes. P(0 changes)=14P(\text{0 changes}) = \frac{1}{4}, P(2 changes)=P(HHH)+P(TTT)+P(HTH)+P(THT)=14P(\text{2 changes}) = P(HHH) + P(TTT) + P(HTH) + P(THT) = \frac{1}{4}. Total even =12= \frac{1}{2}. ✓

Source: Mathematical folklore / probability puzzle

Type: ProbabilitySource: Mathematical folklore / probability puzzleEdit on GitHub ↗