Skip to content

Commit 0ccefd4

Browse files
committed
Itertools 5
1 parent de65523 commit 0ccefd4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Itertools/Compress the String!.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Compress the String!
2+
# https://www.hackerrank.com/challenges/compress-the-string/problem
3+
4+
from itertools import groupby
5+
6+
data = input()
7+
groups = []
8+
for key, value in groupby(data):
9+
groups.append((len(list(value)), int(key)))
10+
print(*groups)

0 commit comments

Comments
 (0)