An unambiguous encoding is synonymous with a [uniquely decodable code](https://en.wikipedia.org/wiki/Variable-length_code#Uniquely_decodable_codes). | |
One approach is to use the fact that [prefix codes](https://en.wikipedia.org/wiki/Prefix\_code), i.e. codes where no whole codeword is a prefix of any other codeword, are uniquely decodable. For instance, if \(C_1\) starts with a dash, then output the prefix code [`.-`, `..-`, `...-`, etc.], else output the prefix code [`-.`, `--.`, `---.`, etc.]. | |
Doing so, \(C_1\) cannot possibly be a prefix of the other codewords (and vice versa) due to its differing first index. This yields a solution where \(|C_i| \le N\), though there are other approaches that take advantage of the generous length limit. | |
[See David Harmeyer's solution video here.](https://youtu.be/6Xgt70dfvNk) | |