Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started