Solution 2: Functions cannot return arrays. A pointer to the first element of an array can be obtained. In this case, the first element of the array is actually an array itself (a row in a matrix). The syntax required to declare a pointer to an array ( function returning ) is too c...
It is possible to convert it into a run-length encoding (RLE) in a single step. rle = ''.join(['{}{}'.format(k, sum(1 for _ in g)) for k, g in groupby(string)]) Thekrepresents the letter being grouped, withgbeing an iterator that produces the same letter N times....