In the 1980s, the Internet was mostly text-based. Similarly to how today we use emojis 🦊 🚲 and abbreviations (like LMK or LOL) to embellish messages, early Internet users (and some gamers today) used a modified spelling called leet (meaning, "elite") where certain letters are replaced with numbers that look similar (such as replacing "s" with "5" or "e" with "3").
For example, can you read this text?
1 w4nt t0 g0 t0 5ch001 34rly t0d4y.
You're going to build a l33t
block that converts just one specific letter to a number (such as just changing "e" to "3").
Your block will need to need to:
You've already learned how to use map
to apply a function to every item in a list, and how to use join
to join elements of a list into a single text string. The missing ingredient is a letter-changing function.
And add "Write out a sentence in L33T (on paper)" and then "See id you can read someone elses." exercises to the end of the first page above.
change for letter
block that takes one input called letter. This block will decide whether to change one letter at a time. For example, if you were changing "e" to "3", your new block would look like this:Click for a reminder about how to create a new block.
Click for a reminder about how make a block take an input.
letter
), and press "OK."
You can use the block to decide which thing to report. The
if then else
block takes three inputs:
A predicate is a hexagon-shaped reporter that asks a true/false question such as these examples:
A conditional is a block that controls the code based on a true/false condition (the predicate). The block is an example of a conditional.
if then else
to write code for your change for letter
block that will test whether the input letter matches the letter you want to change into a number, and if it does, reports the number, and if it doesn't, reports the input letter without changing it.change for letter
block with your chosen letter and with other letters.Map
ping the Letter-Changing Function Over All the Lettersl33t
that takes one input called text, splits that input text into a list of letters, applies your letter-changing function to every item in the list, and joins the letters back together.
Click below for support with:
The block takes two inputs: a string of text and a character by which to split up the text into a list. For example:
You learned to use to apply any block that works on one list item to every list item in Unit 1 Lab 4 Activity 4: Transforming Every Pixel.
Recall that map
takes two inputs: a function with an empty input slot where each item from the list goes every time the function is applied, and a list of items to apply that function to.
You learned to use in Unit 1 Lab 2 Activity 3: Creating and Editing Blocks. It merges two or more strings of text into one (without a space). As you saw in Unit 1 Lab 5 Activity 5: Programming a Caesar Cipher,
join
can accept a single list as input.
l33t
block for different words and phrases. It should report the exact same word or phrase as the input except that the one letter you choose should be replaced by the number you chose to replace it.l33t
block. For example: To easily make a new block that is similar to your letter-changing function (such as change e to 3 for letter
), you don't need to start all over again. Instead, just right-click on the block name in the palette on the left and select "duplicate".
That will create a new block (such as change e to 3 for letter (2)
) and open it for you in the block editor. You can click the text in the hat block to change the name. Then create the code for your new block.
if then else
together with a predicate and the map
block to test each item in a list.