charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'

def encode(bin_string):
    chunks = [bin_string[i:i + 6] for i in range(0, len(bin_string), 6)]
last_chunk_length = len(chunks[-1])
decimals = [int(chunk, 2) for chunk in chunks]
decimals.append(last_chunk_length)
ascii_string = ''.join([charset[i] for i in decimals])
return ascii_string

def decode(ascii_string):
    decimals = [charset.index(char) for char in ascii_string]
last_chunk_length, last_decimal = decimals.pop(-1), decimals.pop(-1)
bin_string = ''.join([bin(decimal)[2:].zfill(6) for decimal in decimals])
bin_string += bin(last_decimal)[2:].zfill(last_chunk_length)
return bin_string
Compress a series of 1s and 0s into the shortest possible ascii string