#C6978. Decoding the Caesar Cipher with Valid English Words
Decoding the Caesar Cipher with Valid English Words
Decoding the Caesar Cipher with Valid English Words
You are given an encoded message that has been encrypted using a Caesar cipher. The encryption was applied word‐by‐word with an unknown shift. To decode the message, you must try shifting each word by all possible amounts (from 0 to 25) until a valid English word is found.
The list of valid English words is limited to the following set: { the, quick, brown, fox, jumps, over, lazy, dog, hello, world, this, is, an, example }.
Maintain the case of letters. For each word, if a valid shift is found (i.e. the shifted word exists in the dictionary, case insensitive), then the word is decoded using that shift. Otherwise, leave the word unchanged.
Note: The input is provided as a single line from standard input and the output should be written to standard output.
inputFormat
The input consists of a single line containing the encoded message.
Example: ymj vznhp gwtbs ktc ozrux tajw ymj qfed itl
outputFormat
Output the decoded message as a single line.
Example: the quick brown fox jumps over the lazy dog
ymj vznhp gwtbs ktc ozrux tajw ymj qfed itl
the quick brown fox jumps over the lazy dog