Your math teacher has created an encrypted message using a substitution cipher. The first person to crack the encryption and find the original message gets to leave class early.
pIZjugwgZ6HkZx6kZjiZg77GtGgHjUkZ76tjiwZ6ZIgvG9wGvgZI tuZ6IZY,LLYLKln
She explained her encryption scheme as follows. First she converts every character in the original message to an integer. The capital letters A
to Z
are encoded as the integers a
to z
are encoded as the integers 0
to 9
are encoded as the integers
Then she uses the formula
If a
character Q
character
You just found a scrap of paper on the floor where the teacher encrypted her name. So you now know that B6Hg
is the encrypted word Jane
. Can you use this information to decrypt the longer message?
The input will contain
The first two lines are a short sample message (unencrypted version, then encrypted version) and the third is the message you have to decrypt using the same method that works for the sample. All three strings will start and end with an asterisk character which is not part of the message. The maximum string length is
Note that there are only two test cases below, but the real data sets will contain
Sample Input
*Jane*
*B6Hg*
*pIZjugwgZ6HkZx6kZjiZg77GtGgHjUkZ76tjiwZ6ZIgvG9wGvgZI tuZ6IZY,LLYLKln*
*135*
*29B*
*,40Va0aT.H0az8a0Y08Fl0Y0kpuk1g08ll0aq0fdddd*
Sample Output
*Is there any way to efficiently factor a semiprime such as 54775723?*
*Is it true that 2 and 2 ALWAYS add to 4????*
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments