Hello! Are you ready for an exciting voyage into the wonderful realm of strings and data structures? Today, we will be assisting Alice, an aspiring cryptographer, with an intriguing string manipulation task. She loves playing with strings and has come up with a unique string encoding scheme. I assure you this will be an enlightening journey that will stretch your programming muscles. Let's get started!
Alice has devised a unique way of encoding words. She takes a word and replaces each character with the next character in alphabetical order. In other words, given a string word
, for each character, if it's not z
, she replaces it with the character that comes next alphabetically. For the character z
, she replaces it with a
.
Another element of Alice's algorithm involves frequency analysis. After shifting the characters, she counts the frequency of each character in the new string. Then she creates an association of each character with its frequency and ASCII value. Each character maps to a number, which is the product of the ASCII value of the character and its frequency. Our task is to construct a list that contains these products, sorted in descending order.
Example
For the input string "banana"
, the output should be [294, 222, 99]
.
The string "banana"
will be shifted to .
