Hello All:
I've been trying this for the last 3 or 4 days and haven't figured it out yet. Any help would be appreciated.
THE PROBLEM:
I am trying to output a sequence or combination numbers, from say, 1 through 5 using only the digits 1 through 5, and all their possible combinations.
Example #1:
digits 1, 2, 3
The possible combinations are...
1,2,3
1,3,2
2,1,3
2,3,1
3,2,1
3,1,2
Example #2:
digits 1, 2, 3, 4
The possible combinations are...
1,2,3,4
1,2,4,3
1,3,2,4
1,3,4,2
1,4,2,3
1,4,3,2
2,1,3,4
2,1,4,3
and so on...
HINT...
I know that each solution should have n! (n factorial) solutions. In other words, for 3 digits (numbers 1 through 2), there are 3! solutions, or 3x2x1 = 6 solutions. For 4 digits, there are 4! solutions, or 4x3x2x1 = 24 solutions. And so on.
I would like to be able to plug in a number, say "X", and get all combinations of all numbers form 1 to "X".
I've tried nesting for loops, trying using one for loop with multiple expressions, etc. However, no success.
Anyone with a lot of brain power want to give it a shot?!
Thanks a bunch!
--
Ed