In this problem, we will learn how to encode the text and decode the encoded message.
If the characters have the same frequency, please order them in alphabetical order.
(Hint: Take into account "space" and use function ord())
There are several lines of text, the input is separated into two-part.
The first part (several lines) which learns the text and encoding rule.
The second part (one line) is the message for you to decode it.
Example Input:
Hello
John
0000000001011000000000101
Note that
1. You can use the function .lower() to convert the character to lower-case.
2. Not all elements are characters.
Encode:
Please encode the least frequency to '1', and order the characters in alphabetical order.
' ' was encoded it to '1'
'e' was encoded it to '01''j' was encoded it to '001'
...
'o' is encode to '000000'
Decode:
You need to decode the input number 0000000001011000000000101 to the character.