S
Size: a a a
S
БГ
V
V
AT
V
M
VA
V
V
VA
Python3
import itertools
def compress(text):
for char, same in itertools.groupby(text):
count = sum(1 for _ in same) # number of repetitions
yield char if count == 1 else str(count)+char
print(''.join(compress("aaabccccCCaB")))
3ab4c2CaB
VA
V
Python3
import itertools
def compress(text):
for char, same in itertools.groupby(text):
count = sum(1 for _ in same) # number of repetitions
yield char if count == 1 else str(count)+char
print(''.join(compress("aaabccccCCaB")))
3ab4c2CaB
V
Python3
import itertools
def compress(text):
for char, same in itertools.groupby(text):
count = sum(1 for _ in same) # number of repetitions
yield char if count == 1 else str(count)+char
print(''.join(compress("aaabccccCCaB")))
3ab4c2CaB
VA
V
VA
V
V