Encrypted Messages
It is Friday noon, and Totos is very tired from all this week's classes, so he decides to communicate with his friend Annoula during a class.
Since they can not be heard talking during the class, they decide to exchange messages on small pieces of paper.
However, last time they tried that, they were caught by their teacher who read their messages out loud for the whole class to hear!
Of course they wanted to prevent that from happening again, so from then on they decided to encrypt and decrypt all the messages they exchange!
In order to avoid catching his teachers attention, Totos needs to be able to read and send messages quickly, so he would like to write a program to automate this procedure.
Your task is to write this program for him.
You will not be given the algorithm for the encryption and decryption of the messages, so you will have to obtain that yourselves from the input and output samples.
For your convenience, the table below contains the ASCII values for the uppercase latin letters and the space character.
ASCII is a data-encoding format that assigns standard numeric values to letters, numerals, punctuation marks, and other characters used in computers so that we can process them more easily.
Character | (space) | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ASCII value | 32 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 |
In Python programming language you can convert a character to its ASCII value using the function ord()
and an ASCII value to its corresponding character using the function chr()
. In C/C++/Java you don't need an instruction for that and you can handle the characters as if they are their corresponding ASCII values.
Input
The first line of input contains either ENCRYPT
or DECRYPT
which represents whether you need to encrypt or decrypt (respectively) the message that follows.
The second line of input contains the message that needs to be encrypted or decrypted which will consist of at most 500 uppercase letters or space characters.
Output
In a single line, output the encrypted or decrypted the message as requested.
Examples
1st
STDIN
ENCRYPT
ENIGMA
STDOUT
HQLJPD
2nd
STDIN
ENCRYPT
THE CAKE IS A LIE
STDOUT
WKH FDNH LV D OLH
3nd
STDIN
DECRYPT
WKH FDNH LV D OLH
STDOUT
THE CAKE IS A LIE
Comments