Compress the String! - Python Solution. The following shows how to solve the HackerRank Compress the String! Python itertools problem.
Code:
import itertools
print(*[ ( len(list(g)), int(k) ) for k, g in itertools.groupby(input()) ])
Test Input:
1222311
Test Output:
(1, 1) (3, 2) (1, 3) (2, 1)