ST EK List:
5.5.1F Compound expressions using and, or, and not are part of most programming languages.
5.5.1G Intuitive and formal reasoning about program components using Boolean concepts helps in developing correct programs.

Solving a Word Puzzle

On this page, you will solve a crossword puzzle by combining predicates using the and block. You will then use the resulting predicates with keep to find words with specific characteristics.

keeping words with 6 letters with 1st letter r and 3rd letter d
  1. Click here to load this file. Then save it to your Snap! account.
    Run import words list to initialize the words list variable.
  2. You have used the length of () block in the Operators palette together with = and keep to find words of a certain length in the words list.
    1. Reassemble that script so that you can find all the words that have 8 letters.
    2. Find all the words that have 11 letters.
    3. You now have an expression that you can edit to test any word for any number of letters. This is a useful tool to have. Create and test a predicate block that takes a word and number as input and works like this: does (orange) have (6) letters? reporting true does (apple) have (7) letters? reporting false
  3. Build an expression using the letter () of () block with = and keep to find words that have certain letters in certain places.
    1. Use it to find all the words that begin with the letter i.
    2. Find all the words whose fourth letter is r.
    3. Your block's title can be different from the one shown here as long as it does the same job.
    4. If you have not yet turned your expression into a predicate block, do that now. Your block should work like this:
      is letter (4) of (carrot) the letter (o)? reporting false is letter (2) of (giraffe) the letter (i)? reporting true
  4. Work with another pair. Use your predicates, along with and and keep, to solve this Unit 2 Lab 3 Word Puzzle.
    For example, this expression searches for 6 letter words that start with r and have d as the third letter: keeping words with 6 letters with 1st letter r and 3rd letter d

    All the words in the puzzle are related to the AP CS Principles course.

    Solving a Word Puzzle
  5. Now Is a Good Time to Save
 
  1. Create and test a predicate block that checks whether a certain letter is in a word. Examples below. Your block should:
    • Accept two inputs: a letter to check for and a word, and
    • Report whether or not the inputted word has the inputted letter.
    is there a (w) in (Boston)? reporting false is there a (w) in (New York)? reporting true