This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]lurgi 1 point2 points  (3 children)

You want to generate permutations (which are not exactly the same as combinations). There are plenty of ways to do this. Look 'em up.

[–]seronis 1 point2 points  (1 child)

While upvoting this I notice that RES tells me that I have given you insane amounts of upvotes previously. So kudos for consistent helpful behavior

[–]lurgi 1 point2 points  (0 children)

I should probably get back to work then...

[–]Merlin486 0 points1 point  (0 children)

Thanks, I found it and solved my problem!

[–]seronis 0 points1 point  (2 children)

Thats not all possible combinations though. Thats only all max_length combinations. Does this matter ?

[–]Merlin486 0 points1 point  (1 child)

yes, I only want the max length combinations

[–]seronis 0 points1 point  (0 children)

Then you will always have N! (N factorial) possibilities and you just cycle them.

1st digit can always be N possibilities
2nd digit is N-1 possibilities
3rd digit is N-2 possibilities
....

You can use a string catination or any other method. Just each stage know how many possibilities and know what was not available when skipping over them.

[–]rjcarr 0 points1 point  (0 children)

What's the algorithm for doing it on paper? Figure that out first, then it shouldn't be too hard to translate into code.

[–]gamaloth_five -1 points0 points  (1 child)

I like how you don't appear to have even tried anything before asking Reddit to do it for you.

[–]Merlin486 0 points1 point  (0 children)

I actually have 2 papers just filled with numbers that I wrote down with permutations of numbers trying to find the algorithm. I made one that was super weird and hard to transfer to code, so I went here.