Answered step by step
Verified Expert Solution
Question
1 Approved Answer
FIGURE 9.1. Pictorial representation of the first five triangular numbers. In[1]: Anagrams1[word String] := Module[[words), words Map[StringJoin, Permutations [Characters[word]]]; DictionaryLookup[/; MemberQ[words, x]]] In[2] Timing
FIGURE 9.1. Pictorial representation of the first five triangular numbers. In[1]: Anagrams1[word String] := Module[[words), words Map[StringJoin, Permutations [Characters[word]]]; DictionaryLookup[/; MemberQ[words, x]]] In[2] Timing [Anagrams1["alerts"]] Out [2] (16.3502, (alerts, alters, salter, staler}} In[3]: Anagrams2[word String] := Module[(chars Characters[word], words), words Map[StringJoin, Permutations[chars]]; In[4] ] DictionaryLookup [Alternatives @ words] Timing [Anagrams2["alerts"]] Out [4] (0.940914, (alerts, alters, salter, staler}} In[5]: Anagrams3[word String] := Module[(len = StringLength [word], words), words DictionaryLookup [RegularExpression["\\w"> ToString[len] ""]]; Select [words, Sort [Characters[+]] = Sort [Characters[word]] &]] In[6]: Timing [Anagrams3["alerts"]] Out [6] (0.052693, (alerts, alters, salter, staler}}
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