All submissions for this problem are available.
We have some textual documents that we need to read, but the documents are encrypted and we need to decrypt them, given the key.`
We call the content of the encrypted sentence, the "ciphertext". We call the content of the decrypted sentence -- which is the same as content that was originally encrypted by our encryption algorithm -- the "plaintext".
Fortunately, all the documents that we've encrypted (all the plaintexts) are of a simple form: words separated by spaces, commas, and periods; the words are made up only of ASCII letters.
The encryption algorithm is trivial. For a given plaintext, and a given encryption key (which is a word as defined above), the algorithm produces a ciphertext. The ciphertext is the same length as the plaintext.
If a plaintext character is *not* a letter, then the corresponding ciphertext character is the same as the plaintext character.
If a plaintext character *is* a letter, then that plaintext character is part of a plaintext word. The characters of a plaintext word are encrypted by applying a function ("encryption function") to the plaintext word.
To define the encryption function, we first define something called the "encryption pad". The encryption pad is an infinite sequence of characters produced by concatenating the key to itself infinitely many times. For example, if the key were "Wow", then the encryption pad would be "WowWowWowWow...".
For each plaintext character of the plaintext word -- say, the N'th character -- we select a character ("pad character") from the encryption pad that is at the same offset (i.e., the N'th character from the encryption pad). So, for example, if the plaintext word were "Super", and the key were "Wow", then, for the plaintext character, 'e', we would select the pad character, 'W'. Then the ciphertext character is determined from the plaintext character and the pad character as follows:
For a pad character of 'a' or 'A', the ciphertext character is equal to the plaintext character (i.e., the character is unchanged). For a pad character of 'b' or 'B': 'a' becomes 'b' 'b' becomes 'c' ... 'z' becomes 'a' (and similarly for upper case letters: 'A' becomes 'B', etc.) For a pad character of 'c' or 'C': 'a' becomes 'c' 'b' becomes 'd' ... 'z' becomes 'b' (and similarly for upper case letters: 'A' becomes 'C', etc.) And so on for other pad characters. Your job is to write a complete program to help with this
- The first line of the input will be any line of cipher text and second line will be the key of encryption algorithm
- Your program should decrypt the sentence and output the decrypted sentence to standard output. The program should produce no other output..
Input: Cv lik ok Grofers
Output: We get it
The very first letter of plain text was capital W when we encrypt it with key Grofers then it became C, same algorithm when you will apply for all letters you will get cipher text ...
|Time Limit:||1 sec|
|Source Limit:||10000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.