Solution (source code)

= Solution

A rate-$R$ block code consists of an encoder $E_n:J^n\to\{1,\ldots,M_n\}$ and decoder $D_n$, with $M_n\leq2^{nR}$; it is reliable when $\Pr[D_n(E_n(U^n))\ne U^n]\to0$. Choose $\varepsilon>0$ with $H(U)+\varepsilon<R$. The <typical set> has probability tending to one and cardinality at most $2^{n(H(U)+\varepsilon)}\leq2^{nR}$. Encode its words injectively and map every atypical word to a default codeword. The error probability is at most the atypical probability, so reliable compression exists.