Solution (source code)

= Solution

For $0\leq q<1$, use <repeat-until-success coding over an erasure channel>: \b[delete every erasure symbol from the received sequence and retain the non-erased bits in order]. Each message <bit> contributes a string of erasures followed by exactly one correct non-erased copy. The <channel encoder> advances to the next <bit> only after this successful copy, so the retained <bits> are precisely $W_1,\ldots,W_n$. Hence
$$
\boxed{d(Y)=W,\qquad\Pr(d(Y)\ne W)=0.}
$$
Indeed, $\Pr(M_j>k)=q^k\to0$, so each stage and the finite collection of $n$ stages terminate <almost surely>. The protocol uses <channel feedback>: Alice must know whether an erasure occurred before deciding whether to repeat. This feedback is implicit in the stated algorithm and is not counted as a forward <channel> use.

At $q=1$, no stage ever finishes, so there is \b[no terminating zero-error decoder for arbitrary messages]. This endpoint is excluded from the operational claim above.