Cody Pendant has asked for the
wisdom of the Perl Monks concerning the following question:

I've asked about this before but I'll be the first to admit I'm stuck on the recursion/logic of it.

By the way, there is, as far as I know, no openly-source or free anagram engine anywhere. There are some good websites (http://www.wordsmith.org/anagram/) , but no offline Perl solution that I can find.

So, assuming that I have already created a dictionary-hash of "ur-words" where

then, what's my next move? Because for single words (in the answer), it's a no-brainer. Sort letters, lookup either fails or it doesn't, here are your words.

But for multiple words in the answer? (that website gives nearly 1300 possible anagrams for "perl wisdom") I need to use a permutation algorithm on my input string, then index through each permutation, looking for a string which matches a word in my dictionary ... then look at the left-over letters and perform the same process, then the left-overs of that process..? This is where it all gets a bit misty for me.

Any help gratefully received. Which permutation module/algorithm should I use for a start? For long strings the amount of permutations is huge.

By the way, there is, as far as I know, no openly-source or free anagram engine anywhere.
Look harder. There are lots of open source anagram programs around. With all kinds of features. Isn't it one of the standard "BSD games"?

First thing you do is delete from your %dictionary all ur-words that contain any letters not present in your source phrase. Another preprocess you can do is eliminate all ur-words that are already too long.

If anybody has any tips on how to install the C anagram generator on Mac OS X, I'd love to hear them.

Yeah - treat it like Unix. You do know that OS-X is BSD with Aqua as the windowing manager, right?

Being right, does not endow the right to be rude; politeness costs nothing.Being unknowing, is not the same as being stupid.Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

That's a pretty dumb idea because the number of permutations grows even worse than exponentially. For instance, my /usr/share/dict/words contains 45427 entries, which is only slightly more than 8!, the number of permutation you get with 8 different letters.

If you don't want to use one of the many canned solutions that are out there (and why wouldn't you?), a reasonably efficient solution goes as follows:

For all words in the dictionary, create a histogram of said word. If the histograms are identical, the words are anagrams of each other. (If you want to find words that can be made from a subset of the letters, look for anagrams which have values equal or less than your search word. For solutions with spaces (groups of words), recurse.)

But it's much better to use an existing solution written in C (C is much faster than Perl for this kind of work), and just qx it.

[Your Mother]:I like it. I tottered on going into hucksterism because I feel like the world deserves it.

[LanX]:he ... we have a movement here called Anti-Germans based on this

[Corion]:Your Mother: I think that's because (in the west) the Nazi-Germans are recognized as universally evil. Of course, you could do some number games to calculate other measures of evil than "historic losers of second world war" to come up with other evils:)

[Corion]:I've heard "Troll" described as the new Punk, and in a way, it can be as destructive as living the Punk lifestyle, and you don't have to sit out in the cold...