#C4608. Mirror Encryption
Mirror Encryption
Mirror Encryption
You are given a string s
consisting solely of lowercase English letters. Your task is to encrypt the string using the mirror encryption algorithm.
The algorithm works as follows: for each character c
in the input string, determine its position from the beginning of the alphabet (with a
at position 0). Then, replace c
with the character that is in the same position from the end of the alphabet. In mathematical terms, if the position of c
is represented as \( pos = \text{ord}(c) - 97 \), the encrypted character \( c' \) is given by:
\( c' = \text{chr}(122 - pos) \)
For example, the letter a
(position 0) is replaced with z
(position 25), b
is replaced with y
, and so on.
Your program should read an input string from stdin and write the encrypted string to stdout.
inputFormat
The input is a single line containing a string s
consisting of lowercase English letters only.
Example:
a
outputFormat
Output the encrypted string corresponding to the input according to the mirror encryption algorithm.
Example:
z## sample
a
z