4

How do I create a list of all possible anagrams of a word in javascript?If this question has already been asked please direct me to the answer?

Thank You

manraj82
  • 5,929
  • 24
  • 56
  • 83
  • 1
    Possible duplicate of http://stackoverflow.com/questions/5232295/is-there-any-pre-built-method-for-finding-all-permutations-of-a-given-string-in-j – Town Jun 02 '11 at 15:01

1 Answers1

6

Here you go: Anagrams finder in javascript

I'm not sure whether that's the exact same problem as yours, but there look to be a few good solutions in the answers.

EDIT: Actually, this is what you need: Is there any pre-built method for finding all permutations of a given string in JavaScript?

Community
  • 1
  • 1
Town
  • 14,706
  • 3
  • 48
  • 72
  • @Town Im not trying to find or compare anything, I just need all the anagrams sorted in an array – manraj82 Jun 02 '11 at 14:21
  • Do they need to be valid words? Eg: for `town`, you'd get `nowt` and `wont`, but not `wnot` ? – Town Jun 02 '11 at 14:27
  • @Town It doesnt have to be valid words,just all possible anagrams sorted like this abcd,abdc,acbd,acdb,adbc,adcb...... Im only bother about the sorting not the validity,thanks – manraj82 Jun 02 '11 at 14:30
  • 1
    @manraj82: So what you actually want are all permutations of characters of a given set. – Felix Kling Jun 02 '11 at 14:43
  • @Felix yes thats what im looking for.. you could say im looking for an anagram creator – manraj82 Jun 02 '11 at 14:46
  • @manraj82: You could say that... although what Felix says is probably more correct as an anagram is _a word, phrase or name formed by rearranging the letters of another_. – Town Jun 02 '11 at 14:50
  • @town sorry,is that not what i asked? Apologies if the question is confusing – manraj82 Jun 02 '11 at 14:56
  • @town Is this question still a duplicate of "Anagrams finder in javascript"? – manraj82 Jun 02 '11 at 14:58
  • @manraj82: No, it's a duplicate of [this](http://stackoverflow.com/questions/5232295/is-there-any-pre-built-method-for-finding-all-permutations-of-a-given-string-in-j) :) – Town Jun 02 '11 at 15:02
  • The link you posted only works for 3 letter words. I would say its not a sufficient answer (+1 for link though). Another critical missing step/suggestion is sorting out the fake words checking against something like a prefix trie. http://stevehanov.ca/blog/index.php?id=120 – Bryan Potts Jul 08 '14 at 16:20