Greetings! You are on your journey to Mars and need to send encrypted transmissions back to Mission Control on Earth. However, someone forgot to bring the instructions for the encryptor machine, and it’s up to you to figure out how it works!
The encryptor has 10 black box functions that each encrypt a string in a different way. Your mission is to try each encryptor on various inputs to figure out how it works. Once you think you see the pattern, you’ll try to write your own function that tries to match what the encryptor does. You can then use some tests from our support file to see whether your version is correct.
Include this at the top of your program:
import shared-gdrive("support.arr", "1vZOpk94JH2DJOzO1xAf5ZYFX5ENuzhQP") as support
Now you will be able to access all of the encryptors and their testers in your pyret file.
The encryptor functions are named
support.encryptor1,
support.encryptor2,
support.encryptor3,
support.encryptor4,
...
support.encryptor10
The encryptor functions take in strings as input (e.g: support.encryptor1("earth")
) and produce an encrypted result (run this expression to see what the first encryptor does).
Note: Please keep a record of what strings you use to test each encryptor – you should be prepared to explain your choice of strings to a TA. You can do this by writing your calls (uses) of the encryptor functions in the definitions window.
The tester functions are named, inspiringly,
support.test-encryptor1,
support.test-encryptor2,
support.test-encryptor3,
support.test-encryptor4,
...
support.test-encryptor10
To use them, you must use the name of your function as an input. For example, if you wrote the function:
fun my-cool-encryptor(str :: String) -> String:
#some code here
end
You would test whether it is correct by running:
support.test-encryptor1(my-cool-encryptor)
Hint: The encryptors are composed of functions from the Pyret strings library. Start out by reading through it for an idea of what kinds of operations the encryptors might use.
Call over a TA once you have completed: encryptor4, encryptor7, and encryptor10.
Oh no – you just received a transmission from Earth that alien ships from Mars are heading towards you! According to mission control, they must have broken your encryption scheme. It’s up to you to create new encryption functions that the Martians won’t be able to figure out but Mission Control will still understand.
In a new document, write your own encryptor function. Call it new-encryptor
. It must take in a single string and produce some output. You may use any combination of functions from the Pyret strings library to build your function.
Once you’re done, press the “Publish” button in the Pyret Code Editor and trade links with another group. Use the same format that you used to import support.arr
– Call over a TA if you get stuck. As you did with our encryptors, try to reproduce your classmates’ encryptor.
Call over a TA once both groups have solved each other’s encryptors.
The goal of this lab was to help you get comfortable experimenting with code and with writing functions. Sometimes, you find out about a new function (perhaps something you found in the documentation) and need to be able to try it out to figure out what it does. This lab tried to help you get a sense of how to experiment with a new function/operator, while also giving you some practice writing functions of your own.