Skip to content

Files

Latest commit

ab2579d · May 5, 2020

History

History

runLengthDecode

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 12, 2020
May 5, 2020

Run-Length Decode

Note: Do runLengthEncode first.

Let's write a function runLengthDecode that decompresses run-length encoded data. As with runLengthEncode, we'll assume that the original string didn't contain any numbers. This sidesteps any ambiguity in the run-length encoded data.

In general, the following condition should hold:

runLengthDecode(runLengthEncode('Apple pies are delicious')) === 'Apple pies are delicious';
runLengthDecode(runLengthEncode(input)) === input;