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.

-
You have used the
block in the Operators palette together with
=
andkeep
to find words of a certain length in the words list.- Reassemble that script so that you can find all the words that have 8 letters.
- Find all the words that have 11 letters.
- 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:
-
Build an expression using the
block with
=
andkeep
to find words that have certain letters in certain places.- Use it to find all the words that begin with the letter i.
- Find all the words whose fourth letter is r.
- If you have not yet turned your expression into a predicate block, do that now. Your block should work like this:
Your block's title can be different from the one shown here as long as it does the same job. -
Work with another pair. Use your predicates, along with
and
andkeep
, 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:All the words in the puzzle are related to the AP CS Principles course.

Take It Further…
-
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.
Create this block:
The first input is a pattern, which is a word in which some of the letters have been replaced by hyphens (minus signs).