Skip to content

Latest commit

 

History

History

compress-the-string

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Compress the String!

https://www.hackerrank.com/challenges/compress-the-string

Problem

In this task, we would like for you to appreciate the usefulness of the groupby() function of itertools.

You are given a string S. Suppose a character 'c' occurs consecutively X times in the string. Replace these consecutive occurrences of the character 'c' with (X, c) in the string.

Input Format

A single line of input consisting of the string S.

Output Format

A single line of output consisting of the modified string.

Sample Input 0

1222311

Sample Output 0

(1, 1) (3, 2) (1, 3) (2, 1)

My Solution