A ticker tape stores text in a compact run-length form: it is a sequence of pairs, where each pair is a single lowercase letter immediately followed by a positive integer count (which may have more than one digit). Reading left to right, every pair <letter><count> stands for that letter repeated count times.
Given such an encoded string, print the fully expanded text. The input is guaranteed to be well-formed: it is a concatenation of pairs, every count is at least 1, and there are no separators.
Line 1: a non-empty run-length encoded string as described above.
A single line: the expanded text.
Example 1
Input
a3b2c1
Expected
aaabbc
Explanation
a repeated 3 times, b repeated 2 times, c repeated once, giving 'aaabbc'.
Example 2
Input
x10
Expected
xxxxxxxxxx
Explanation
The pair x10 means x repeated 10 times, giving ten x characters.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →