Order the symbols so that . For each , there are exactly binary strings of length , while precisely the indices
satisfy . Assign those symbols bijectively to the strings of length . The resulting map is an injective function and hence a one-to-one source code, with . 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.