ZOJ Problem Set - 2240
Your task is to write a program that performs a simple form of run-length encoding, as described by the rules below.
Any sequence of between 2 to 9 identical characters is encoded by two
characters. The first character is the length of the sequence, represented by
one of the characters
Any sequence of characters that does not contain consecutive repetitions of
any characters is represented by a
The input consists of letters (both upper- and lower-case), digits, spaces, and punctuation. Every line is terminated with a newline character and no other characters appear in the input.
Each line in the input is encoded separately as described above. The newline at the end of each line is not encoded, but is passed directly to the output.
Source: University of Ulm Local Contest 2004