Compress the String!
-
hackerrank.com Practice>Python>Itertools>Compress the String!hackerrank.com 2019. 2. 7. 21:43
Compress the String! TipThis is quite simple problem if you understand how to use groupby()Focus two variables(k and g) are iterated from groupby()As an example groupby('aaabb'), g is 'aaa', and k is 'a' Solution from itertools import groupby s = input() o = [(len(list(g)), int(k)) for k, g in groupby(s)] print(*o)