LearnPy Hub
← Arena
EasyRating 1000

Run-Length Encoding

Compress a string by replacing each run of identical characters with the character followed by the run length.

Input

A string of lowercase letters.

Output

The encoded string, e.g. aaab → a3b1.

Sample 1

Input
aaabccdddd
Output
a3b1c2d4

Sample 2

Input
x
Output
x1
solution.py
Output appears here
Run-Length Encoding · Python Arena problem · LearnPy Hub