Jane Street interview question

Code 3 functions on Run Length Encoding