Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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

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

The Core Ios Developer S Cookbook Core Recipes For Programmers

Authors: Erica Sadun ,Rich Wardwell

5th Edition

0321948106, 978-0321948106

More Books

Students also viewed these Programming questions