Run Length Decoding Python answer
an anonymous user
·
Python
def run_length_decoding(compressed_seq: str) -> str:
seq = ""
current_letter = None
for character in compressed_seq:
if character.isalpha():
if current_letter is not None:
seq += current_letter * int(number)
current_letter = character
number = ""
else:
# We assume that this is the number following the letter.
number += character
if current_letter is not None:
seq += current_letter * int(number)
return seq
print(run_length_decoding("A2B3C11"))
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.