Compression of random binary data

Marko Rauhamaa marko at pacujo.net
Mon Oct 23 06:13:56 EDT 2017


Thomas Jollans <tjol at tjol.eu>:

> On 2017-10-23 11:32, danceswithnumbers at gmail.com wrote:
>> According to this website. This is an uncompressable stream.
>> 
>> https://en.m.wikipedia.org/wiki/Incompressible_string
>> 
>> 1234999988884321
>
> No, it's not. According to that article, that string is incompressible
> by a particular algorithm. I can see no more general claims.

Here's a compression algorithm that manages to compress that string into
a 0-bit string:

 * If the original string is 1234999988884321 (whatever that means),
   return the empty bit string.

 * Otherwise, prepend a don't-care bit to the original string and return
   the result of the concatenation.

>> It only takes seven 8 bit bytes to represent this
>
> You amaze me.
>
>>>> bin(1234999988884321)
> '0b100011000110011100111010111101000101001001101100001'
>>>> len(bin(1234999988884321)[2:])
> 51
>>>> 7 * 8
> 56

So danceswithnumbers made a correct statement!

Anyway, a fun troll.


Marko



More information about the Python-list mailing list