Solving a Word Puzzle

Nobody would have to ask a computer "Does spaghetti have 5 letters?" The block should be retitled WORD ( ) HAS ( ) LETTERS so that it looks more sensible. --bh

Then chase the change forward into 5.1 starting on page 2, editing started files, solutions, and TG in both units as needed. --MF, 7/14/20

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.
  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.
    Can we hint this?
    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. Save your work
  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 input word has the input letter.
    is there a (w) in (Boston)? reporting false is there a (w) in (New York)? reporting true
  2. Tough Stuff Create this block:
    words matching (-e-u--c--g) from (word list)
    The first input is a pattern, which is a word in which some of the letters have been replaced by hyphens (minus signs).