# Lesson goal: Finding patterns in Pi (more)

Previous: Patterns in Pi ($\pi$) | Home | Next: Introduction

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.

string.find(haystack,needle)

# Now you try. Fix the the string.find line to search for num within bigpi.

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. Dismiss.
Show a friend, family member, or teacher what you've done!