All problems
Run-Length Decoding
Problem
Decode a run-length encoded string where each character is followed by the number of times it repeats, so a3b2c1 decodes to aaabbc.
Counts may have more than one digit. Return the empty string for empty input; assume the input is well formed.
Hint
Hold the pending character until the next character or the end of the string.
Test cases
case 1
in: ["a3b2c1"]
expected: "aaabbc"
case 2
in: [""]
expected: ""
case 3
in: ["a1"]
expected: "a"
case 4
in: ["x10"]
expected: "xxxxxxxxxx"
case 5
in: ["a2b2a2"]
expected: "aabbaa"
Starter codePython
def run_length_decode(s):
# Your code here
pass5 test cases · run your code against them in the editor