Here are  functions “encodeString” and “decodeString” that will encode and decode a string like ‘AAAAABBBBAAA’ as a list of tuples: [(‘A’, 5), (‘B’, 4), (‘A’, 3)] meaning that the string has “5 A’s, followed by 4 B’s, followed by 3 A’s”.

Scroll to Top