1 year ago

#343455

test-img

parth hirpara

Image compression with specific block size and max run length

I need to write two functions called compress(S) and decompress(S) that take a binary string S of length less than or equal to 64 as input and return another binary string as output. The output binary string should be a run-length encoding of the input string.

COMPRESSED_BLOCK_SIZE = 5

MAX_RUN_LENGTH = 2 ** COMPRESSED_BLOCK_SIZE - 1

>>>compress( 64*'0' )
'1111100000111110000000010'

>>>uncompress('1111100000111110000000010')
'64*0'

python

binary

compression

run-length-encoding

0 Answers

Your Answer

Accepted video resources