3 ms·
As https://news.ycombinator.com/item?id=25531532 https://news.ycombinator.com/item?id=25531532 said look up arithmetic coding (https://en.wikipedia.org/wiki/Ari
by Someone 6y ago
As https://news.ycombinator.com/item?id=25531532 https://news.ycombinator.com/item?id=25531532 said look up arithmetic coding (https://en.wikipedia.org/wiki/Arithmetic_coding https://en.wikipedia.org/wiki/Arithmetic_coding)
It’s not 100% the same, but understanding it should enable you to use the same idea for this problem.