The roman cipher
Description
Discuss (8 comments)
Back in the roman empire, a cipher was used to exchange secret message between Cesar and his centurions. The goal of this puzzle is to write a decoder for this cipher.
The encryption consists in taking a message, for example "Ave and Welcomus to Coderus Charti" and a number of columns, for example 5.
The encryption is performed in 3 phases.
In phase 1: the message is written vertically on the columns. For the last column, if the message ends before the last row, it is completed with dots (.). For the previous message, the phase 1 would look like this:
So for the previous example, the output should be:
The encryption consists in taking a message, for example "Ave and Welcomus to Coderus Charti" and a number of columns, for example 5.
The encryption is performed in 3 phases.
In phase 1: the message is written vertically on the columns. For the last column, if the message ends before the last row, it is completed with dots (.). For the previous message, the phase 1 would look like this:
A uoC vWsdh ee ea ltrr acout no si dmC .In phase 2: the even rows (2,4,...) are reversed. The phase 2 processing looks like this:
A uoC hdsWv ee ea rrtl acout is on dmC .In phase 3: the rows are concatenated to form a string, the final encrypted message thus looks like this:
A uoChdsWvee earrtl acoutis ondmC .
Input Specifications
The input file contains two lines:- the number c of columns
- the encrypted message
5 A uoChdsWvee earrtl acoutis ondmC .
Output Specifications
The output result must be printed on the standard output. The result to be printed is the decoded message. The extra padding dots (.) must not be removed.So for the previous example, the output should be:
Ave and Welcomus to Coderus Charti.
© CoderCharts - All Rights Reserved
| Type | Puzzle | Pass | 247 | Fail | 94 | ||
| Scoring | Language | Level | Novice | Points | 400 | ||
| Tags | cryptography, string manipulation | ||||||
Unit Tests
| Name | CPU Unit | Memory Unit |
|---|---|---|
a real messageThis test has at most 1500 characters |
Confirm that you want to switch languages
Your current edits will be lost.
Confirm that you wish to load a previous submission
Your current edits will be lost.