Practice
Junior Example Problem 1: Folding Cipher
What are Folding Cipher?
-
A cipher uses the following process to encrypt a message:
- Write out the message all in upper case.
- Determine the position in the alphabet of the first letter of the message (E = 5, M = 13 and so on). Find the remainder when that number is divided by 3 and add 3 to the remainder (ie 'E' yields 5, 'M' yields 4 and so on).
- Rewrite the message in a table using the number calculated in step 2 as the width of the table, working across each row in turn.
- Prepare the ciphered message by copying down the columns in turn.
Example
- As an example, take the message 'I WILL ARRIVE MONDAY'. 'I' is character 9 of the alphabet. Dividing 9 by 3 yields a remainder of 0, adding 3 to the remainder yields 3, so we write the message across 3 columns:
I W ILL AR RIV E M OND AY
- Reading down the columns we obtain as the ciphered message:
II REOA LAI NYWLRVMD
Instructions
- Write a program which will correctly DECIPHER a message prepared using this cipher and use it to decrypt the message below.
- For clarity, spaces have been replaced by "*".
- No other output should be produced by your program other than the decoded message on one line.