how do i display all alternatives that can be matched using n different characters
eg:
a b c d
a b d c
a c b d
and so on...until all different unique combinations are made
a b c
b a c
b c a
c a b
c b a
Printable View
how do i display all alternatives that can be matched using n different characters
eg:
a b c d
a b d c
a c b d
and so on...until all different unique combinations are made
a b c
b a c
b c a
c a b
c b a
I haven't tested this, so you might have to modify a bit, but i think it should work if you call permutations and pass the string (don't pass any large ones)
Code:Sub permutations(byval a as string,byval optional b as string)
Dim n as integer
if len(a) then
for n=1 to len(a)-1
permutations left(a,n-1) & mid(a,n+1),b & mid(a,n,1)
next n
else
print b & " ";
end if
end sub