Results 1 to 5 of 5
 07212012, 05:00 PM #1Member
 Join Date
 Jul 2012
 Posts
 3
 Rep Power
 0
How many possible groups in a serial of number, I need all of the goups
Hi,
Just don't know how whether it can be written a program in Java that performs such a logic. Seems very complicated because I need all of the possible groups
Here's a simple example.
1 2 3 4 5 6 7
in these seven numbers
I just choose four of them. Can I write a jave program to list out all of the possible groups if I choose four of them?
For example
1 2 3 4 can be a group
2 3 5 6 also can be a group
......
I need to list out all of the possible groups and they should be order from small to large.
If I didn't do a wrong calculation, it may be 840 possible groups totally.
I have no idea about how to write such a program to fulfill such a logic in Java. Is it possible???
Thanks.
 07212012, 08:42 PM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,432
 Blog Entries
 7
 Rep Power
 20
Re: How many possible groups in a serial of number, I need all of the goups
Is, say, 1 2 3 4 different from 4 3 2 1? (the same numbers but in a different order).
kind regards,
Joscenosillicaphobia: the fear for an empty beer glass
 07222012, 04:12 AM #3Member
 Join Date
 Jul 2012
 Posts
 3
 Rep Power
 0
Re: How many possible groups in a serial of number, I need all of the goups
 07222012, 08:49 AM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,432
 Blog Entries
 7
 Rep Power
 20
Re: How many possible groups in a serial of number, I need all of the goups
So you want all C(n,m) combinations? (in your example C(7,4) == 7!/(4!*3!) == 35); have a look at the following method; given a 'group' stored in array 'c', the method generates the next group, given the size 'n' of the elements to pick from:
Java Code:public static boolean combine(int[] c, int n) { for (int i= c.length; i >= 0;) { if (++c[i] <= n(c.lengthi)) { for (; ++i < c.length; ) c[i]= c[i1]+1; return true; } } return false; }
kind regards,
Joscenosillicaphobia: the fear for an empty beer glass
 07222012, 05:02 PM #5Member
 Join Date
 Jul 2012
 Posts
 3
 Rep Power
 0
Similar Threads

Serial number of exernal hard disk/Thumbdrive
By manucng in forum NetworkingReplies: 13Last Post: 11142011, 08:09 AM 
Serial communication via ethernetserial hub
By Idiodyssey in forum New To JavaReplies: 0Last Post: 05042011, 02:23 PM 
serial communication is very slow while reading from serial port
By elsanthosh in forum AWT / SwingReplies: 1Last Post: 07302010, 08:29 AM 
Help me to get RAM serial number
By Ajitha in forum New To JavaReplies: 5Last Post: 06052010, 02:30 PM 
Geting Mobile Number, Mobile Operator, Location and Mobile Serial Number by J2ME.
By maruffaiz in forum CLDC and MIDPReplies: 1Last Post: 08072009, 12:14 PM
Bookmarks