Howitt's Anagram Theory
I am reading Dan Brown's "The Da Vinci Code" and in addition to the fact that it is a great read chock full of geek codebreaking goodness, it renewed my interest in anagrams.
Employing my best Java to write an anagram generator I am trying to work out the quickest way to generate all the possible anagrams of a sentence in as little time as possible.
During my search I came across what appears to be a solid fact about anagrams (please post a comment if you find it to be inaccurate): the total number of unique anagrams generated from an input string n characters long will be n! (factorial) divided by the the product of all the u! (factorial) where u is a unique character in the input string e.g. aaabb will be 5!/(3!*2!) = 10
I haven't found a case where this doesn't work but similarly don't have a full mathematical proof either.