0% found this document useful (0 votes)
18 views

Snake

The document describes a cipher encryption puzzle. A string of text was encrypted by first reversing the letters in each word, replacing spaces with random numbers, and then applying a substitution cipher. The goal is to write code to decrypt the encrypted string and reveal the hidden message.

Uploaded by

Declan Ng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Snake

The document describes a cipher encryption puzzle. A string of text was encrypted by first reversing the letters in each word, replacing spaces with random numbers, and then applying a substitution cipher. The goal is to write code to decrypt the encrypted string and reveal the hidden message.

Uploaded by

Declan Ng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Snake

Goal
Decrypt the cipher.

Description
Omer spent many hours working on python lessons and exercises, and
wanted to have something else for a change.

He found the perfect thing and wanted to upload it to the exercise site, but
when he did – the CYBER MONSTER came and started messing it up!

She changed the order of the letters in every word (so ‘hello’ became ‘olleh’),
and then she changed every space (’ ’) to a random number (for example,
after both of the changes above, “hello make my world” became
“olleh2ekam5ym9dlrow”).
As if that wasn’t enough, the monster then used a substitution cipher, and
changed each letter to a different one, using this dictionary:

{'s': 'L', 'b': 's', 'w': 'O', 'z': 'G', 'c': 'o',
'J': 'y',
'V': 't', 'P': 'w', 'B': 'f', 'Z': 'q', 'F': 'k',
'O': 'N',
'u': 'A', 'W': 'r', 'K': 'K', 'a': 'D', 'v': 'l',
'g': 'S',
'f': 'x', 'x': 'c', 'N': 'e', 'p': 'b', 'U': 'a',
'j': 'P',
'o': 'Q', 'i': 'I', 'M': 'd', 't': 'U', 'H': 'V',
'X': 'i',
'Y': 'T', 'R': 'H', 'h': 'X', 'L': 'z', 'G': 'F',
'A': 'W',
'm': 'n', 'T': 'u', 'l': 'B', 'C': 'Z', 'q': 'p',
'D': 'v',
'I': 'g', 'n': 'h', 'y': 'C', 'S': 'j', 'k': 'M',
'd': 'J',
'Q': 'E', 'e': 'Y', 'r': 'R', 'E': 'm'}
Finally, the following string came out:

"YXu8hYq6xQ8,hQXUCw9Cs7nIu1LRYUYw\n\nBAxIUADYf6LI5RY
UUYs4hDX
U7.CBSA\nUIoIBbcm2LI6RYUUYs7hDXU3.UIoIBbnI\nYBbnIj5L
I8RYUUYs
0hDXU8.cYBbnQo\ncYBbnQZ0LI4RYUUYs4hDXU9.JYUDoIBbnQo\
nUDBk8LI
8RYUU
Ys4hDXU0.JYULYh\nYLRDbj6LI1RYUUYs9hDXU1.YLhYJ\nCUIBI
sD
JDYH8.LUhAQo\nBDIoYbj7LYLDo8U'hYRD2BDIoYbL4XSAQhY6QU
5MDYRs1Y
XU2.LYBAR\nXSAQXUBW7CUIBDoIUoDRb6LUDYs0.CUIRAb\nLRQR
Rm3JBAQX
L5RYlYh7LL
Db8.CBUhYBIL\nLLYBha3CBUIoIBbcY6.JYohYBIL\nhg2YXU
3YoDx6xQ5,CUIASIsnD5YLAxYR5YXU2hQIUDUbnYU6QU1.LLYAS\
nYRYXu4J
BAQXL0Ys8--YhQ9JhD4CBsDRYxYRb3CBhQ5YhQ3LAQIlsQ-
-4CDO5QU8QJ9.
UI\nXSAQXUBW4UD
XU6CDO7CDn3UQh4Ys4LAQIlsQ2UD8ULRIx5LLYBhA4YR
'AQC9.XoUAv\nOQe5LI7RYUUYs9hDXU4.RYlYh\nXSAQXUBW9RYl
Yh8LI5hY
UxQ7RYUUYs7hDXU4*UXSIR*0.OQh\nxg9YXU0hQIUDUhYnYBbnI5
LI9JRDX3
QU9,hIDBbcY3L'UI0D3J
Ds8.DYJI\nxg7YXU2hQIUDUhYnYBbnI4LI2CLDY
1QU3,hIDBbcY7UI5CDn3Ys8D8JQQS5.DYJI\nLYoDbLYnDe7YRD6
YhQ8ShIM
hQX2UDYRS4DYJI4--8L'UYB1QJ8YRQn6xQ9!YLQXU"

Nice, right? Beat the CYBER MONSTER and read the message!

Steps
Implement both the encrypt() and decrypt() functions
Add tests in a test() function, using assert and various inputs
Implement main() function

To submit
Name the file snake.py before submitting

Notes
1. \n is a single character symbolizing a new line.
2. You do not need to parse the attached file, you may simply use the
string within it.

Good Luck!

You might also like