|
Hedge-cryption
Okay, well, our previous encryption did not work...but we at the Faculty of Informatics are famous for not giving up! Gaining knowledge from our previous failure we were able to develop our next, "state-of-the-art" cryptosystem! This new technology, simply named hedge-cryption is surely unbreakable, so it provides us with a system which can be used to protect even the most sensitive government secrets as well. We are so sure that this system is unbreakable that we think that it is unnecessary to test it at all. Soooo...technically there is no exercise here, thank you for your attention.
Oh, of course, before I forget: I really need to tell you how to use this fantastic new system:
- We are provided with the unencrypted, plain text and a given n height.
- The encryption is done from left to right in a "diagonal" way.
- For easier understanding we will use 1, 2, 3,... as indexing in this explanation, however in actual programming you most likely need to shift from 0, 1, 2,... (depending on the chosen programming language of course). During encryption the first letter of the unencrypted text goes to the first character of the first line. The second letter goes to the second place of the second line, the third character goes to the third place of the third line. We continue this diagonal descend until we reach the n-th letter of the n-th line. Then with a similar diagonal technique we start to ascend diagonally right and up. After we reach the top we start to descend again.
- The encryption must finish at the 1st line, so maybe it is necessary for you to pad your unencrypted text with - characters.
- To get the encrypted text after you create this diagonal hedge you just simply need to concatenate the letters line by line from left to right to a whole string.
Input
The input consists of two lines:
- The first line consists of a single n integer which gives us the height of the "hedge".
- The second line is the unencrypted t string.
Output
The output is the encryption of the given encrypted text with the technique described above. An important note is that maybe you are required to append some - characters to the end of your unencrypted message, since you are required to finish the encryption in the "top line". During the exercise you must use the least amount of - characters.
Restrictions
- n is at most 100
- the length of t is at most 1000
- t contains only the small letters of the english alphabet
Example
Explanation
a e e i - p l i d l c o s p s i u
download as text file
|
|