|
-
Nov 22nd, 2007, 08:26 AM
#1
Thread Starter
Fanatic Member
[2005] Get all possible combinations of a word letters
Hi!!!
I have a List with letters with a max length of 10. Lets say for example I have the letters "D","A","D","O". How can I get all the possible combinations that these letters can form like:
DADO
DAOD
DODA
DOAD
DDAO
DDOA
ADDO
ADOD
AODD
ODDA
ODAD
OADD
In this case i would get 4!/2! combinations because there are two "D". So to have this DADO and switch the "D" i get the same that why I divide it by 2!.
-
Nov 22nd, 2007, 08:31 AM
#2
Re: [2005] Get all possible combinations of a word letters
-
Nov 22nd, 2007, 08:37 AM
#3
Thread Starter
Fanatic Member
Re: [2005] Get all possible combinations of a word letters
not that see what he says:
Also, I want to mention that the list objects that will be passed to the method should have unique objects in order to get unique lists of objects. For example if we have a set {A,A,B,C} then the method will return:
and in my example i gave the letters DADO two D.
I want like this
Well but maybe I can find the solution from there.
Last edited by Lasering; Nov 22nd, 2007 at 09:08 AM.
-
Nov 22nd, 2007, 11:47 AM
#4
Re: [2005] Get all possible combinations of a word letters
You do realize that with 10 possible combinations you can end up with an astronomically big set, right? I've always wondered what the purpose was when people wanted to get all combinations of something like this. What are you going to do with it?
My usual boring signature: Nothing
 
-
Nov 22nd, 2007, 12:33 PM
#5
Thread Starter
Fanatic Member
Re: [2005] Get all possible combinations of a word letters
Well. I'm at 12 grade and on Math class. I think my teacher is doing something wrong (well she's not that good teacher, she gets wrong a lot). So I tried to explain to her why. But still she says she right, and probably she is. But I want to be sure. So I want to add to a list box all the values of the combinations. And then delete the ones that dont fit the exercise.
The exercise is like this: How many combinations can you form with the word "INFINITO", so that the letters IN stay always together. In other words you have to have always either IN or NI in the string.
-
Nov 22nd, 2007, 12:38 PM
#6
Re: [2005] Get all possible combinations of a word letters
This is more math than anything. Simple combinations. You have 8 letters, and they can be in any order, such that an I and an N always appear next to each other. So you have 8 possible letters that can go in the first spot. If that letter is an I or an N, you know the next letter has to be the opposite. With two of each, you know that there are only two letters that can fit that criteria. The rest is just a simple factorial. 8*2*6*5*4*3*2*1. If that makes any sense.
-
Nov 22nd, 2007, 01:17 PM
#7
Re: [2005] Get all possible combinations of a word letters
Actually, I think you might better understand the question when it is approached like this:
Since the letters I and N always have to stay together, let us consider them as one letter, and disregard the fact that there are 3 I's and 2 N's for the moment.
So with our 6 letters, and our 1 lassoed pair, we have a total of 7! possible combinations.
Now, what about the fact that there are 3 I's? All this means is that there are 3 possible ways of forming 'IN' with reference to the letter I, so now our total goes up to 7! * 3
How about the 2 N's? Again, this means that there are 2 possible ways of forming 'IN' with reference to the letter N, so now our total goes up to 7! * 3 * 2
Finally, since 'IN' can also be written as 'NI', we have to double our existing total to account for each possible time that 'IN' could have been 'NI'. This brings our final total to 7! * 3 * 2 * 2 = 60,480.
Whenever you are dealing with problems like this, with more than one of the same letter that has to be considered, it sometimes helps to substitute different symbols in their place to help you get started. Then when you have a basic result, factor them back in. So essentially what we did was find the total possible permutations of the combination 'N' and 'I', and then bring that into our larger permutation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|