A short message has been compressed with a simple run-length scheme. The compressed form is a sequence of tokens written back-to-back. Each token is a positive integer count (written in ordinary base-10 decimal digits) immediately followed by exactly one lowercase English letter. A token means "repeat this letter count times". Expand the whole compressed string and print the original text.
For example the token 4a expands to aaaa. Tokens simply concatenate, so 2x1y expands to xxy.
A single line containing the compressed string. It is a non-empty concatenation of tokens, where each token is a decimal integer with no leading zeros (at least 1) followed by one lowercase letter a-z. There are no spaces.
A single line: the fully decoded string.
Example 1
Input
3a2b1c
Expected
aaabbc
Explanation
Token 3a -> aaa, token 2b -> bb, token 1c -> c. Concatenated they give aaabbc.
Example 2
Input
1a1b1c1d
Expected
abcd
Explanation
Every count is 1, so each letter appears once, giving abcd.
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 →