Caesar Cipher Decoder
Contest 2
In ancient Rome, Julius Caesar encrypted military messages by shifting each letter in the alphabet by a fixed number of positions. Modern cryptographers call this a Caesar cipher. While trivially breakable today, it remains a building block for understanding encryption.
You are given an encrypted message and a shift value. Your job is to decrypt it.
Decryption rules:
- Each uppercase letter (A-Z) is shifted BACKWARD in the alphabet by the shift value, wrapping around if necessary. For example, with shift : becomes , becomes , becomes .
- Each lowercase letter (a-z) follows the same rule but stays lowercase.
- Spaces, digits, punctuation, and all other characters remain unchanged.
After decrypting, output the message AND the number of letter characters (a-z, A-Z) that were shifted.
Input:
- Line 1: an integer , the shift value ()
- Line 2: the encrypted message (may contain spaces, digits, punctuation)
Output:
- Line 1: the decrypted message
- Line 2: the count of letter characters that were shifted
You are given an encrypted message and a shift value. Your job is to decrypt it.
Decryption rules:
- Each uppercase letter (A-Z) is shifted BACKWARD in the alphabet by the shift value, wrapping around if necessary. For example, with shift : becomes , becomes , becomes .
- Each lowercase letter (a-z) follows the same rule but stays lowercase.
- Spaces, digits, punctuation, and all other characters remain unchanged.
After decrypting, output the message AND the number of letter characters (a-z, A-Z) that were shifted.
Input:
- Line 1: an integer , the shift value ()
- Line 2: the encrypted message (may contain spaces, digits, punctuation)
Output:
- Line 1: the decrypted message
- Line 2: the count of letter characters that were shifted
Constraints
. The message is to characters long and contains printable ASCII characters.
Sample input
3 Khoor Zruog!
Sample output
Hello World! 10
Stdin