Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Try to compress, by encoding number of nulls

Language: Layout:
+ ] Show input
Absolute running time: 0.11 sec, cpu time: 0.08 sec, memory peak: 7 Mb, absolute service time: 0,12 sec 
edit mode |  history

Старт программы - попытка сжатия несжимаемых данных,
кодированием количеств нулей в двоичной строке.

binary binary_data:
1010001100000110110000101101000011100011001101000110001101000011010000011 
bitlength = 73 
count(1) =  30 
count(1)/bitlength =  0.410958904109589

how_many_nulls_in_string:
[0, 1, 3, 0, 5, 0, 1, 0, 4, 1, 0, 1, 4, 0, 0, 3, 0, 2, 0, 1, 3, 0, 3, 0, 1, 4, 0, 1, 5, 0]

unique_values [0, 1, 2, 3, 4, 5]

len_unique_values 6

Повторы чисел в массиве:
0 13
1 7
2 1
3 4
4 3
5 2

dictionary {'4': '3', '0': '13', '2': '1', '5': '2', '3': '4', '1': '7'}

dictionary sorted:  [('0', '13'), ('1', '7'), ('3', '4'), ('4', '3'), ('5', '2'), ('2', '1')]

dictionary with codes {'4': '1110', '0': '0', '2': '11111', '5': '11110', '3': '110', '1': '10'} 

numbers ['0', '1', '3', '4', '5', '2']

prefix_code array ['0', '10', '110', '0', '11110', '0', '10', '0', '1110', '10', '0', '10', '1110', '0', '0', '110', '0', '11111', '0', '10', '110', '0', '110', '0', '10', '1110', '0', '10', '11110', '0']

array encoded with prefix code:
010110011110010011101001011100011001111101011001100101110010111100 
len compressed:  66 bits

original data len(binary_data) =  73 bits.

Compressed:
0010110011110010011101001011100011001111101011001100101110010111100

    
                
λ
.NET NoSQL database for rapid development