Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save codeperfectplus/ac74e5ace008b5e9ddb8a8706ea66b50 to your computer and use it in GitHub Desktop.

Select an option

Save codeperfectplus/ac74e5ace008b5e9ddb8a8706ea66b50 to your computer and use it in GitHub Desktop.
# Enter your code here. Read input from STDIN. Print output to STDOUT
import itertools
def compress_the_string(string):
res = itertools.groupby(string)
for k, g in res:
print((len(list(g)), int(k)), end=' ')
if __name__ == '__main__':
string = input()
compress_the_string(string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment