#K84547. Taco String Encoding
Taco String Encoding
Taco String Encoding
Given a string s
, encode it by counting the number of times each character appears consecutively. For example, for a string s where consecutive appearances of a character c appear n times, the encoded format is cn. More formally, if the string is represented as $$s = c_1c_2\ldots c_k$$, then the encoded string is obtained as:
For instance:
- If the input is
aabcccccaaa
, the output must bea2b1c5a3
. - If the input is
abc
, the output must bea1b1c1
.
Your task is to implement the encoding function that performs this transformation.
inputFormat
The input consists of a single line containing the string s
(which can include letters, digits, or symbols). The length of s
can be up to 100,000 characters. Input is read from stdin.
outputFormat
Output the encoded string as described. The answer should be written to stdout.
## sampleaabcccccaaa
a2b1c5a3