To show how strings are compressed, it's necessary to show how the decompressor works. If you give RegPack the tongue-twister
How much wood would a woodchuck chuck if a woodchuck could chuck wood?, it will spit out
How much } w|a }~~if a }~c|~}?~chuck }wood|ould along with the list of characters
The decompressor starts by splitting this string on the first character in the char list,
|, resulting in
["How much } w", "a }~~if a }~c", "~}?~chuck }wood", "ould "]. It then pops the last item,
"ould ", and joins what remains by this, resulting in
"How much } would a }~~if a }~could ~}?~chuck }wood".
It then does the same thing for
wood to result in
"How much wood would a wood~~if a wood~could ~wood?~chuck ", and finally replaces
"chuck " to result in the whole thing,
How much wood would a woodchuck chuck if a woodchuck could chuck wood?.
for(i of<chars>)with(_.split(i))_=join(pop()) (where
<chars> is a hardcoded char list), which basically performs the steps described above.
Your challenge is to, given a compressed string and a list of characters, decompress it using the above algorithm.
'a|b|c|hello', '|' => ahellobhelloc 'He||o, wor|d!|l', '|' => Hello, world! '| | & &&|house|green', '|&' => green green greenhouse greenhouse 'N~give}up,n~let}down~ever gonna } you ', '}~' => Never gonna give you up,never gonna let you down 'How much } w|a }~~if a }~c|~}?~chuck }wood|ould ', '|}~' => How much wood would a woodchuck chuck if a woodchuck could chuck wood? 'She sells~ells by the~ore~ sea sh', '~' => She sells sea shells by the sea shore