Encode run-length
Your task
A log shipper shortens noisy lines before upload. Given a string of lowercase letters, build its run-length form: each maximal run of a repeated character becomes the character followed by the run's length in decimal (lengths can be multi-digit, and 1 is written explicitly). Ship whichever is better: return the encoded form only if it is strictly shorter than the original; otherwise return the original. For example, 'aaabbbbbcc' becomes 'a3b5c2', but 'ab' stays 'ab' because 'a1b1' is longer.
Examples
compress_log(s: str) -> strExample 1
Input
compress_log("aaabbbbbcc")Output
"a3b5c2"