Hi Experts
I need some code to generate all possible unique sets of p groups containing q items taken from an array of r elements. Order not important and P*Q<=R. This seems seems marginally more complicated than most of the links I have found so far.
My current need is specifically for all possible sets of 6 pairs of elements from an array of 12 elements. (i.e. p=6,q=2,r=12)
In simpler terms suppose there were 4 elements and I wanted all possible sets of 2 pairs I would expect (p=2,q-2,r=4)
1,2 3,4
1,3 2,4
1,4 2,3
If there were 5 elements and I wanted all possible sets of 2 pairs, I would expect (p=2,q=2,r=5)
1,2 3,4
1,2 3,5
1,2 4,5
1,3 2,4
1,3 2,5
1,3 4,5
1,4 2,3
1,4 2,5
1,4 3,5
1,5 2,3
1.5 2,4
1,5 3,4
if there were 6 items and I wanted all possible pairs of triplets, I would expect (p=2,q=3,r=6)
1,2,3 4,5,6
1,2,4 3,5,6
1,2,5 3,4,6
1,2,6 3,4,5
1,3,4 2,5,6
1,3,5 2,4,6
1,3,6 2,4,5
1,4,5 2,3,6
etc
Any help gratefully received.
Thanks
PS This was initially posted in http://www.mrexcel.com/forum/excel-q...numbers-3.html
as a reply to an old (Apr 2006) post but has, unsurprisingly, received no replies
Bookmarks