Say I wanted to build an anagram solver. What would be the best way to do this.
Should I try to use the 'factorial' information to generate all the combinations of letters and then check them for legality using a dictionary file.
There are three letters so there will be 3! possible solutions.Code:For example, what word is this: h,e,t teh the <<solution het hte eth eht Answer *the*
(N.b. 3! is read as 3x2x1=6). To calculate the factorial of a number is easy however, creating a permutation generator is more difficult.
Moreover, I would imagine a permutation generator to have a *recursive* solution. (For those who are unfamiliar with the term, it means calling a function from within a function.) Anyone who has tried to create a recursive function will know it's a complete mind f***. lol
Secondly, attempting to solve a word of more than nine letters would take a reasonably long time. Wouldn't it?
How do I this and is this the most efficient way to go about.
Ps. I'm still trying to crack this alegra solver without using binary trees to evaluate nested brackets. It's proving quite difficult. argh