I've researched and found LOTS of similar requests, but nothing was quite what I needed.
Here is my problem. I'm working in C#, and I have a FileInfo[] array with an unknown number of elements in it.
FileInfo[] files = new FileInfo[]
{
new FileInfo(@"C:\a.jpg"),
new FileInfo(@"C:\b.jpg"),
new FileInfo(@"C:\c.jpg"),
new FileInfo(@"C:\d.jpg"),
new FileInfo(@"C:\e.jpg"),
new FileInfo(@"C:\f.jpg"),
new FileInfo(@"C:\g.jpg"),
new FileInfo(@"C:\h.jpg"),
new FileInfo(@"C:\i.jpg"),
}; // Using 9 elements for this example
And I need to generate a list of every possible reorder combination of these files, without repeating the files.
So, some of my results would be like this (example is not in code format):
a, b, c, d, e, f, g, h, i
a, b, c, d, e, f, g, i, h // i & h switched
a, b, c, d, e, f, h, g, i // last 3 elements switched
a, a, b, b, c, c, d, d, e // THIS IS NOT ACCEPTED, because elements are duplicated
And so on, until I've come up with every possible combination
So the total number of results should be the factorial of the number of elements in the array. In this example, there are 9 elements, so there should be 9*8*7*6*5*4*3*2*1=362,880 possible combinations.
I've been messing with this for a couple days now, and I just can't wrap my mind around it. Any help is appreciated, especially with code examples!
Thanks!