I want to find all possible combination of letters and dot â.â Condition is that suppose if we have 2 letter "ab" then using "." in between them we can make combination as âa.bâ Same for 3 letters "abc" we can make possible combination "a.bc", "ab.c" and "a.b.c" Same for 4 letter "abcd" we can make "a.bcd", "ab.cd", "abc.d", "a.b.cd", "a.b.c.d", "ab.cd", "ab.c.d", "a.bc.d" and "abc.d". For the above problem I have tried to make a c++ program to find all possible combinations for any number of letters but I haven't been able to find a good solution.
ReplyI juest bought a Convert FLV to SWF --- Sharing Youtube video with folks On converting FLV to SWF, FLV to SWF Converter is relly the fantastic one. Using this tool, you can convert Youtube(.flv) video to swf and edit flv files before converting.
ReplyHi guys, do not read this article because it is not the updated one, it is still the old one. I'll report this to Codeguru webmaster.
Brad has resolved it for me. Thanks, Brad!
ReplyHi, I have used your combination for char, but when I tried changing it to integers, it did not work. Can you please show me how to make it work for numbers. Thanks. Ed.
ReplyOriginally posted by: Jimmy
Hi, using your algorithms, I've generate combinations for the integers 1..20 : this gives over 1 million combos : thanks for that.
My program needs to filter out some of these combinations eg. don't allow combinations which contain {2,3). No problem there but I want to increase the efficiency of my program both for memory usage and speed. I'm thinking of representing each combination as a bitset and using shift operations for comparisons and filtering out various combinations.
Is there come way I can use your algoritm to come up with all the combinations of 1's and 0's for say 20 bits eg
00000000000000000001 : 1
00000000000000000011 : 1,2
00000000000000000010 : 2
00000000000000000111 : 1,2,3
00000000000000000110 : 2,3
00000000000000000101 : 1,3
....
Originally posted by: jared
what about reverse combos, ie BA, CB, etc.
what about redundancies, ie AA, BB, CC, etc, in the case of unlimited pool.
what about different variants on the letter, ie upper case, lower case, italic, bold, etc.
Is there a general formula for this?
Originally posted by: Paul McKenzie
I've posted another method that overcomes
a) the problems of next_permutation returning false
b) is non-recursive
c) works for any type of data (since it is a template).
In short, it uses a totally different approach in finding combinations using next_permutation.
It is available here:
http://www.codeguru.com/forum/attachment.php?s=&postid=721348
The discussion is here:
http://www.codeguru.com/forum/showthread.php?s=&threadid=241675
Probably I will post an article on it in the near future.
Paul McKenzie
Reply
Originally posted by: raffael cavaliere
I find it not good at all to use recursion when your "n" ie number of item in the collection is greater than 12 or 13. Stack errors are very easy to get when it occurs.
I wrote a small method you can use this way :
//JAVA
int[] list = {0,1,2,3,4,5}; //first elements (set of 6)
int n = 12; //number of items in the collection
while {list != null)
list = Clist(n, list);
public final static int[] CList(int n, int a[])
{
for (int i = a.length - 1; i >= 0; i--)
{
if (a[i] < n - a.length + i)
{
a[i]++;
for (int r = i + 1; r < a.length; r++)
a[r] = a[r - 1] + 1;
return a;
}
}
return null;
}
Reply
Originally posted by: But
What if the location of the letter is important. I.e ABC!=CBA.
AAA
AAB
AAC
ABA
ABB
ABC
ACA
ACB
ACC
BAA
BAB
BAC
BBA
BBB
BBC
BCA
BCB
BCC
CAA
CAB
CAC
CBA
CBB
CBC
CCA
CCB
CCC
Total = 27
So if we can use n letters {A,B,C} and r rows then n^r
Reply
Originally posted by: Big Al
Hi Thanks for your effort, could you explain how to do the same thing in VB?
Thanks
Al van Heerden