Write a program to find all words that can be reduced in this way, and then find the longest one. This exercise is a little more challenging than most, so here are some suggestions: 1. You might want...


Write a program to find all words that can be reduced in this way, and then find the longest one.


This exercise is a little more challenging than most, so here are some suggestions:


1. You might want to write a function that takes a word and computes a list of all the words that can be formed by removing one letter. These are the “children” of the word.


2. Recursively, a word is reducible if any of its children are reducible. As a base case, you can consider the empty string reducible.


3. The wordlist I provided, words.txt, doesn’t contain single letter words. So you might want to add “I”, “a”, and the empty string.


4. To improve the performance of your program, you might want to memoize the words that are known to be reducible.



May 25, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here