In a past lesson we defined variable bigpi to be the
first 10,000 digits of $\pi$. We then used this to look for digits occurrence in $\pi$.
Here's another lesson
that maps each digit of $\pi$ into a letter using the mapping that 0=A, 1=B, 2=C, ... 26=Z.
We've provided a function here called tonum which will convert a search string
of interest into a series of digits. So for example, tonum("hi") would return
78, since "h" is the 7th digits in the alphabet (starting with 0=A), and "i" is the 8th. So
searching for "hi" in $\pi$ would mean to search for the digits "78." Make sense?
In this lesson, you can search for such word-codes in $\pi$ using the built in string
search function called string.find.
Move the mouse over a dotted box for more information.
Now you try. Fix the the string.find line to search for num within bigpi.
Type your code here:
See your results here:
This code will not run! How will you fix the string.find() line to
search for the pattern in variable num within the string bigpi? If your
result is nil, then it means your pattern wasn't found.
Show a friend, family member, or teacher what you've done!
Here is a share link to your code:
Does your code work? Want to run it on your iPhone?
Here's your code:
Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.
Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into
Then click the "Use on iPhone" button that you'll see.