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

JavaScript: How do I find all possible letter combinations of given letters though ..

P: 3
I would like to have a javascript that calculates all possible letter combinations of given letters with number of characters in the output.

However, not the same letter from the given letters more than once, except it is in the given word more than once.

For example:
- Named letters "ABCDE"
- Output letters are 4
- Results could be OKAY: "CBED", "ACED", "DEAB", "BCDE" etc
- But NOT OKAY: "AABC" or "BCCC"

However, if
- Named letters "ABCCD"
- Output letters are 4
- Results could be OKAY: "CBEC", "ACCD", "DABC", "ABCC" etc
- But NOT OKAY (more than 2 C's, as it is in the given word): "AABC" or "BCCC"
Jul 31 '13 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
the number of possibilities is given by Permutation.

for the implementation I’d use an array and lots of loops.

note however, that the number of your results get soon very big (5 out of 10 is already > 30,000; 10 out of 20 is > 670,000,000,000).
Jul 31 '13 #2

P: 3
Thanks Dormilich for your reply
Jul 31 '13 #3

Post your reply

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