Solution (source code)

= Solution

For the uniform 27-symbol model, $s=\lceil\log_2 27\rceil=5$. The <uniform-source Huffman length distribution> gives
$$
\boxed{n_4=32-27=5,\qquad n_5=54-32=22.}
$$
Thus five symbols receive four-bit <codewords> and the other 22 receive five-bit <codewords>. To realize these lengths, start with all 32 binary words of length five and collapse any five disjoint sibling pairs into their four-bit parents. This leaves exactly five leaves at depth four and 22 at depth five. All source letters have the same probability, so which five letters receive the shorter <codewords> is arbitrary.

The <expected codeword length> is
$$
\boxed{L=\frac{5\cdot4+22\cdot5}{27}=\frac{130}{27}\approx4.815\text{ bits per symbol}.}
$$
The 27 symbols may represent 26 letters and a space, but this idealization keeps them equiprobable; it is not an empirical frequency model of English.