Please understand am not sure if this is the place for my question if not then please remove.

I need to solve all possible combinations of the solution to n!

So if 5! then there are 120 possible combinations so how do I work out what they are…?

I did solve this once many years ago but my brain seems to have seized up with regard to this as have been working on it for a couple of weeks but no luck.

[quote=101321:@Ian Cartwright]Please understand am not sure if this is the place for my question if not then please remove.

I need to solve all possible combinations of the solution to n!

So if 5! then there are 120 possible combinations so how do I work out what they are…?

I did solve this once many years ago but my brain seems to have seized up with regard to this as have been working on it for a couple of weeks but no luck.

Thanks for any help in advance.[/quote]

Here is a method that returns all the permutations for a delimited character string as a string array…
(E.g. “1.2.3” will give you [“1.2.3”, “2.1.3”, “2.3.1”, “1.3.2”, “3.1.2”, “3.2.1”])

It also has an optional delimiter parameter so that you can change the delimiter if you need to.

Function Permutations(s As String, delimiter As String = ".") As String()
Dim tmpArr() As String
Dim perms() As String
Dim result() As String
Dim firstStr As String
Dim i As Integer
Dim j As Integer
tmpArr = Split(s, delimiter)
if tmpArr.Ubound <= 0 then
result.Append tmpArr(0)
else
firstStr = tmpArr(0)
tmpArr.Remove(0)
perms = Permutations(Join(tmpArr, delimiter))
for i = 0 to perms.Ubound
tmpArr = Split(perms(i), delimiter)
for j = 0 to tmpArr.Ubound + 1
tmpArr.Insert(j, firstStr)
result.Append(Join(tmpArr, delimiter))
tmpArr.Remove(j)
next j
next i
end if
return result
End Function