Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python application that uses recursion to generate all possible anagrams for a phrase taken from user input, then prints those that consist only

Write a Python application that uses recursion to generate all possible anagrams for a phrase taken from user input, then prints those that consist only of valid English words. Treat blanks as characters; you do not need to generate anagrams that contain more or fewer blanks that are present in the input phrase. Convert all letters to lower case before you generate the anagrams. The output must not contain any duplicates.

Using a file named wordsEn.txt, as the source of the list of valid English words, compare each word in the anagram to a line, make sure that if any word in the created anagram is not found in the file it does not print.(Do not worry about the file itself just the name of the file) write code to read it in. Use an iterator to read one line at a time. Each line of the file contains one word. Strip any whitespace from each line and make sure you do not add any newlines to the word list

Use this Pseudocode to generate the annograms recursively

if text.length == 1 return {letters} # Set containing one string. When created, the list will consist of one string with one letter, but it is a set of strings, not a set of chars. else ret = set() for each letter in the string anagramize the rest of the string

add to the set each of the anagrams prepended by the letter you left out return ret

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

b. Does senior management trust the team?

Answered: 1 week ago

Question

c. How is trust demonstrated?

Answered: 1 week ago

Question

Have issues been prioritized?

Answered: 1 week ago