By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,381 Members | 1,640 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,381 IT Pros & Developers. It's quick & easy.

Anagrams

100+
P: 147
Given a dictionary of words, and a phrase, I want to find all possible combinations of words such that their letters form an anagram of the phrase. For instance:
Words: STACK, STICK, I, LIE, ALE, TALE, SICK
Phrase: I LIKE CATS
Anagrams: I LIE STACK, I ALE STICK, TALE I SICK

I've written a function to convert each word to a signature representing the number of times each of its letters appears, in alphabetical order (so SINNING would reduce to G2I3NS), and another function which can find a combination of words which form an anagram of the phrase. But I am stumped on how to find all of the possible combinations. Or more accurately, how to eliminate the first combination found and move on to the next, since some words can appear in multiple different anagrams.

Thanks for any help.
May 30 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.