I am having a hard time to generate a list of unique collection combinations of different sizes for a set, say ,where n=6 [variable]
set = {2,3,4,5,6,7}
I need to generate all unique combinations for the above set using javascript (Ordered collection) like this
6C1 + 6C2 + 6C3 + 6C4 + 6C5 + 6C6
2 2,3 2,3,4 2,3,4,5 2,3,4,5,6 2,3,4,5,6,7
3 2,4 2,3,5 2,3,4,6 2,3,4,5,7
4 2,5 2,3,6 2,3,4,7
5 2,6 2,3,7 2,4,5,6,7
2,7 2,4,5,6
. 2,4,5 2,4,5,7 3,4,5,6,7
. 3,4 2,4,6 .
8 3,5 2,4,7 2,5,6,7 .
3,6
3,7 2,5,6 3,4,5,6
2,5,7 3,4,5,7
4,5
4,6 2,6,7 3,5,6,7
4,7
3,4,5 .
5,6 3,4,6 .
5,7 3,4,7 .
.
. 3,5,6
6,7 3,5,7 4,5,6,7
3,6,7
.
.
5,6,7
Now the complication comes when I need to assign each of these values to alphabetical order.The order is small letters first a,b,c.. and then capital letters A,B,C,.. and after that aA,aB,aC and so on
a=2 h=2,3 o=2,3,4 I=2,3,4,5 2,3,4,5,6 2,3,4,5,6,7
b=3 i=2,4 p=2,3,5 J=2,3,4,6 2,3,4,5,7
c=4 j=2,5 q=2,3,6 K=2,3,4,7
d=5 k=2,6 r=2,3,7 2,4,5,6,7
l=2,7 L=2,4,5,6
. s=2,4,5 M=2,4,5,7 3,4,5,6,7
. m=3,4 t=2,4,6 .
g=8 n=3,5 u=2,4,7 N=2,5,6,7 .
o=3,6
p=3,7 v=2,5,6 O=3,4,5,6
w=2,5,7 P=3,4,5,7
q=4,5
r=4,6 x=2,6,7 Q=3,5,6,7
s=4,7
y=3,4,5 .
t=5,6 z=3,4,6 .
u=5,7 A=3,4,7 .
.
. B=3,5,6
6,7 C=3,5,7 W=4,5,6,7
D=3,6,7
.
.
H=5,6,7
I know that a normal Brute Force way of approach would be the simplest solution to the problem but for large values this would be quite inefficient.
I am looking for a more efficient method of solving this problem. Any good solutions would be of great help.
Thanks in Advance, Neal