Skip to main content
1 of 2
halirutan
  • 113.4k
  • 7
  • 266
  • 479

One way to go through all possible permutations is the NextPermutation function from the Combinatorica` package. But one word of advice: Did you really think through what you are trying to do?

Let's say you just want to loop through 14! iterations and you will do nothing than to increment a counter. This is one of the most basic operations and it takes almost no time at all. Let's see how far you come in 1 minute:

i = 0;
TimeConstrained[Do[i++, {14!}], 60]

After this minute, I have finished 0.19% of the 14! iterations. It took a minute iterating over nothing to accomplish 0.19%!! Now assume you have a task which needs at least a small amount of time. For instance 1/1000 of a second. With this amount of work per cycle, you will need

14!*1/1000./60/60/24
(* 1009.01 *)

1000 days until you are done. Almost 3 years.

You should probably reconsider the importance of your task. If it is for instance a computation you need for your phd, you will probably run out of money before you have your results.

halirutan
  • 113.4k
  • 7
  • 266
  • 479