2

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.)

orome
  • 12,819
  • 3
  • 52
  • 100
  • 1
    Can you have a look at this one and see if it is of help? https://mathematica.stackexchange.com/a/46125/187 – halirutan Aug 10 '18 at 16:04
  • 1
    @halirutan That's from 2014 and uses `Combinatorica``. Does that still work? In my experience each new version of MMA completely breaks fundamental things in the previous one. – orome Aug 10 '18 at 16:06
  • 2
    Does your list have a lot of duplicates? Iterating through 60! permutations does not sound very realistic. – jkuczm Aug 10 '18 at 16:26
  • 2
    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. – Bill Aug 10 '18 at 16:33
  • @orome Have you at least skimmed through my answer there? I was more pointing to the fact that the OP there tried to calculate 14! permutations and I made a rough estimate of the time he needs: "1000 days until you are done. Almost 3 years." – halirutan Aug 10 '18 at 16:35
  • @halirutan Have you at least skimmed through my question here? I was more about asking whether it could be done, than whether it should be. – orome Aug 10 '18 at 16:49
  • 5
    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. – halirutan Aug 10 '18 at 17:05
  • 2
    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. – Mr.Wizard Aug 10 '18 at 18:00
  • @Mr.Wizard The answers are old, as the question states. – orome Aug 10 '18 at 21:45
  • @orome Old does not mean invalid, and you have not made a case for them being "outdated." Further (1283) continues to receive new answers, the last being only from last year. Again, if you want your question separate and open you need to make a case how your question in fundamentally different, and how none of those answers apply to it. – Mr.Wizard Aug 10 '18 at 21:56

0 Answers0