Solution (source code)

= Solution

Order the symbols so that $p_1\geq p_2\geq\cdots$. For each $l\geq0$, there are exactly $2^l$ binary strings of length $l$, while precisely the indices
$$
2^l\leq i\leq2^{l+1}-1
$$
satisfy $\lfloor\log i\rfloor=l$. Assign those $2^l$ symbols bijectively to the strings of length $l$. The resulting map is an <injective function> and hence a <one-to-one source code>, with $L^*(x_i)=\lfloor\log i\rfloor$. Assigning shorter available words to more probable symbols also shows that this is an <optimal one-to-one binary code>.

Solved by gpt-5.6-sol high.