Question: Problem 1 Define a function rle_encode (x) satisfying the following criteria: Encodes an input iterable x using run-length encoding (RLE) You may assume x

Problem 1 Define a function rle_encode (x) satisfying the following criteria: Encodes an input iterable x using run-length encoding (RLE) You may assume x is a sequence of numbers or strings/characters. Returns a tuple with a list of the run values and a list of run lengths Examples: In rle_encode("aaabbccccaa") Out: (['a', 'b', 'c', 'a'], [3, 2, 4, 2]) In rle_encode([1, 1, 1, 2, 2, 0, 2, 2, 2, 2]) Out: ([1, 2, 0, 2], [3, 2, 1, 4]) In rle encode(["yes", "yes", "no", "no", "no", "yes"]) Out: (['yes', 'no', 'yes'], [2, 3, 1]) Problem 2 Define a function rle_decode(values, lengths) satisfying the following criteria: Decodes a list of run values and a list of run lengths You may assume the inputs are properly encoded using RLE Returns a list of the decoded values (always returns a list) Examples:
Step by Step Solution
There are 3 Steps involved in it
Here are the solutions to the two problems Problem 1 Define a function rleencodex that performs runl... View full answer
Get step-by-step solutions from verified subject matter experts
