Performs Run Length Decoding >>> run_length_decode([('A', 4), ('B', 3), ('C', 2), ('D', 1), ('A', 2)]) 'AAAABBBCCDAA' >>> run_length_decode([('A', 1)]) 'A' >>> run_length_decode([('A', 2)]) 'AA' >>> run_length_decode([('A', 3), ('D', 6), ('F', 3), ('C', 3), ('A', 2),
(encoded: list)
| 27 | |
| 28 | |
| 29 | def run_length_decode(encoded: list) -> str: |
| 30 | """ |
| 31 | Performs Run Length Decoding |
| 32 | >>> run_length_decode([('A', 4), ('B', 3), ('C', 2), ('D', 1), ('A', 2)]) |
| 33 | 'AAAABBBCCDAA' |
| 34 | >>> run_length_decode([('A', 1)]) |
| 35 | 'A' |
| 36 | >>> run_length_decode([('A', 2)]) |
| 37 | 'AA' |
| 38 | >>> run_length_decode([('A', 3), ('D', 6), ('F', 3), ('C', 3), ('A', 2), ('V', 4)]) |
| 39 | 'AAADDDDDDFFFCCCAAVVVV' |
| 40 | """ |
| 41 | return "".join(char * length for char, length in encoded) |
| 42 | |
| 43 | |
| 44 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected