--- tags: Labs-F23, 2023 title: Lab 01 --- # Lab 1: Message Decryptor ## Problem 0 - Get to know each other! Welcome to CSCI 0111 Lab! We're *so* excited to work with you. Now that you're with your partner(s), discuss one/some/all of these questions: * What is your favorite food? * What is your favorite kind of rubber duck? * What do you do for fun? <!--## Problem 1 - Following Steps WE'RE SKIPPING THIS THIS SEMESTER :) Go right to Problem 2. Exchange your ```program-steps.pdf``` from Homework 1 with your partner's. Follow their written steps to create the image they had in mind. Once both of you have finished creating the images, compare them to the ```program-image``` file that it was supposed to look like. What was challenging about creating an image from written steps vs. the visual reference? --- ### CHECKPOINT: **Call a TA over to discuss the question above and show them your images!** --- --> ## Problem 1 - Data in the Real World: Google Ads ![this-ad-thinks-it-knows-you](https://i.imgur.com/0HCbaPc.png) We begin this lab by demonstrating how data plays a role in your life, whether you are aware of it or not. For example, information that a search engine has on you comes from a combination of your profile and predictions that the search engine makes about you. These predictions are based on your browsing history, users that are similar to you, etc. Look at some of the information that Google gathers and infers about users. You can check your own data by visiting https://myadcenter.google.com/ or look at the picture below for an example. ![ad-personalization information](https://i.imgur.com/h8E3t3U.png) Using either your data or the picture above identify pieces of information that are inferred about you by Google With your partner, **discuss how Google may have come to infer those assertions about you and how this information might be used when making ad targeting decisions**. ___ ### CHECKPOINT: **Call over a TA to discuss an example of something you found surprising when looking over the data.** ___ ## Problem 2 - Cracking Encryptors You're on a top secret mission and need to communicate an encrypted message containing important code. However, the instructions to your encryption machine were accidentally thrown into the bathtub, and it’s up to you to figure out how it works! The encryptor machine has 10 black-box functions that encrypt a String. Your first task is to test various inputs and figure out how each function changes the input based on the output. Once you have an idea of what an encryption function does, write a version of the functionthat encrypts a String in the same manner and run it through the checks in the support file. If all checks pass, then you’ve successfully built an encryptor for covert communications! **Hint:** The encryptors are composed of functions from the [Pyret Strings library](https://www.pyret.org/docs/latest/strings.html). Start by reading through it. ### Instructions Include this at the top of your program: ```import shared-gdrive("lab1-support-2022.arr", "1kS_-rd0eE9-DLndIYw-0Bez8c6J73MRK") 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("mystery")```) and produce an encrypted result. :::info 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. They will be useful for you to reference, too! ::: 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, after giving some inputs to `support.encryptor1`, you may think it always returns the String `"cs0111"` (*HINT: it doesn't do this -- just an example*). Then you would write the function: ``` fun my-cool-encryptor(str :: String) -> String: "cs0111" end ``` You would test whether your function is correct (meaning it does the same thing as `encryptor1` for all inputs) by running: ``` support.test-encryptor1(my-cool-encryptor) ``` **Hint:** The [Pyret Strings library](https://www.pyret.org/docs/latest/strings.html) will be very helpful when writing your functions! **Hint:** When choosing Strings to use as inputs to the encryptors, it will be useful to vary your inputs -- think about why this could be. In what ways can you vary your Strings? ___ ### CHECKPOINT: **1. Call over a TA after you have finished encryptors 1-4. 2. Call over a TA after you have finished encryptors 5-8.** ___ Now it's time to prove your encryptor expertise - let's solve the final two encryptors in the `support` code, `support.encryptor9` and `support.encryptor10`. --- ### CHECKPOINT: **Call over a TA once you have finished encryptors 9-10.** --- ### Optional Task: Now that you're an encryptor expert, try cracking someone else's encryptor! **Task 1:** Import another group's encryptor from the encryptor swap spreadsheet using the same format you used to import `support.arr` -- call over a TA if you get stuck. **Task 2:** Write a function called `new-decryptor` that takes in the output of the other group's `new-encryptor` and decrypts it. When you think your decryptor works, consult with the other group. ## Success! Nice! Your new encryptor functions worked! You successfully sent the code and the mission was completed. ------ > Brown University CSCI 0111 (Fall 2023) > Do you have feedback? Fill out [this form](https://forms.gle/3n8VyP7tF3ANqGAj7). <iframe src="https://forms.gle/3n8VyP7tF3ANqGAj7" width="640" height="372" frameborder="0" marginheight="0" marginwidth="0">Loading…</iframe>