2
$\begingroup$

I need to generate all permutation of a list of integers, but doing so (the list has around 60 elements, is not practical. Is there a way to iterate through all permutations of a list, without first generating all of them?

(There are several related existing questions here, but none are duplicates: the discussions there are old and outdated, at least for the several I've found.)

$\endgroup$
10
  • 1
    $\begingroup$ Can you have a look at this one and see if it is of help? mathematica.stackexchange.com/a/46125/187 $\endgroup$
    – halirutan
    Commented Aug 10, 2018 at 16:04
  • 2
    $\begingroup$ Does your list have a lot of duplicates? Iterating through 60! permutations does not sound very realistic. $\endgroup$
    – jkuczm
    Commented Aug 10, 2018 at 16:26
  • 2
    $\begingroup$ I still happily use `Combinatorica despite people's criticism. Look in AddOns\Packages\Combinatorica\Combinatorica.m and search for NextPermutation. The source code is all there, the algorithm is only six lines, it depends on nothing else and you can quickly test it against example lists to try to convince yourself whether it works or not. $\endgroup$
    – Bill
    Commented Aug 10, 2018 at 16:33
  • 5
    $\begingroup$ Yes, I have and you wrote "I need to generate..." which doesn't sound like a hypothetical scenario to me. So no, I did not understand that this is a question about whether it is theoretically possible. On this site, we provide "... answers to practical, detailed questions" and I'm not sure what else to say what @Bill hasn't already said. $\endgroup$
    – halirutan
    Commented Aug 10, 2018 at 17:05
  • 2
    $\begingroup$ You assert that "none are duplicates" yet you do not reference any of them and explain how your question is actually different. You need to do that if this is to be a separate question. Putting on hold until you clarify. $\endgroup$
    – Mr.Wizard
    Commented Aug 10, 2018 at 18:00

0

Browse other questions tagged or ask your own question.