String processing
Full Question in the image
You are given a dictionary that maps all lowercase English alphabets from
'a' to 'z' to either lor -1.
For a string of length k, you perform the below operation:
• Find the maximum character from index Ito k, and find the dictionary mapping of the respective maximum character.
• If dictionary mapping is 1, increment all characters from Ito k.
• 'a' becomes 'b', 'b' becomes 'c', . 'z' becomes 'a'.
Task
Determine the count of each lowercase English alphabet after N operations.
Please read Full Instructions and Note Please Use Those Images as reference... Please help
https://drive.google.com/file/d/1QVE-utPuKxxxah3P5T5geL93MX1G5vy_/view?usp=sharing
https://drive.google.com/file/d/1b3RT2IBIBMG2Ojob6uGqoDglXHg-Z928/view?usp=sharing
import string
as_l = string.ascii_lowercase
mapping = dict(zip(as_l, as_l[::-1]))
str_input = str(input("Enter the letters: "))
str_output = ''.join(mapping[c] for c in str_input) # assume every c in my_map
print("The inverse mode is:",str_output) # zyxw
Comments
Leave a comment