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
|
766 Discussions
|
Please Login in order to post a comment
from itertools import * inp=input() count=[]
for k, g in groupby(inp): z=len(list(g)),int(k) count.append(z) print(*count)
from itertools import groupby
numbers = input()
count = [(len(list(g)), int(k)) for k, g in groupby(numbers)]
print(*count)
from itertools import groupby
test_input = input()
res = groupby(test_input)
print(' '.join([str((len([item for item in g]),int(k))) for k, g in res]))