I am trying to learn about run length encoding and I found this challenge online that I cant do. It requires you to write a compression function called compression(strg) that takes a binary string strg of length 64 as input and returns another binary string as output. The output binary string should be a run-length encoding of the input string.
compression('1010101001010101101010100101010110101010010101011010101001010101')
'1010101001010101*4'
Here is what I have, but this does NOT find the pattern:
from itertools import *
def compression(strg):
return [(len(list(group)),name) for name, group in groupby(strg)]
I need some help solving this.