TORONTO KIDS COMPUTER CLUB | Aurora Tuesday 10:30 Python Homework 21.07.27.
19751
post-template-default,single,single-post,postid-19751,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Aurora Tuesday 10:30 Python Homework 21.07.27.

31 Jul Aurora Tuesday 10:30 Python Homework 21.07.27.

Question:
You have come up with the following compression technique: for each symbol, write down the number of times it appears consecutively, followed by the symbol itself. This compression technique is called run-length encoding.

Given a sequence of characters, write a program to encode them in this format: The encoding of a line will be a sequence of pairs, separated by a space, where each pair is an integer (representing the number of times the character appears consecutively) followed by a space, followed by the character.

Sample Input 1:
+++===!!!!

Output for Sample Input 1:
3 + 3 = 4 !

Explanation of Output for Sample Input
To see how the first message (on the second line of input) is encoded, notice that there are 3 + symbols, followed by 3 = symbols, followed by 4 ! symbols.


Sample Input 2:
777777……TTTTTTTTTTTT

Output for Sample Input 2:
6 7 6 . 12 T

No Comments

Sorry, the comment form is closed at this time.