We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Itertools
- Compress the String!
- Discussions
Compress the String!
Compress the String!
Sort by
recency
|
816 Discussions
|
Please Login in order to post a comment
My solution:-
Sometimes you need to try to solve the problem with your onw logic. and here is mine, , whats do you think champs ?
from itertools import groupby
Reading input
s = input()
Using groupby to group consecutive identical characters
result = [(len(list(group)), int(key)) for key, group in groupby(s)]
Printing the result with the required format
print(*result)