avatar Bite 286. Decompress

Write a function, called decompress(), that accepts a string and a dictionary as input.

The dictionary maps special character strings to sequences of characters.

The function goes through the argument string and if the character is in the dictionary, it converts it to the corresponding character sequence.  


>>> table = {'$': 's',

             '%': 'y',

             '/': 't'


>>> decompress('P%Bi/e$', table) 

Note that a special character may map to a sequence of characters that ALSO has a special character in it.  


>>> table = {'*': 'c',

             '#': '00',

             '$': '*y',


>>> decompress('$3#', table)

For example the symbol table maps $ to the string *y and * maps to c.

Login and get coding
go back Intermediate level
Bitecoin 3X

50 out of 51 users completed this Bite.
Will you be the 51st person to crack this Bite?
Resolution time: ~29 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 4.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help