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 more than increment a counter and go to the next permutation. Incrementing a counter is one of the most basic operations and should take almost no time at all. Let's see how far you come in 1 minute:
Needs["Combinatorica`"];
i = 0;
perm = Range[14];
TimeConstrained[Do[i++; perm = NextPermutation[perm], {14!}], 60]
After this minute, I have finished 0.003% (i/14!*100.0
) of the 14! iterations. It took a minute iterating over nothing to accomplish 0.003%!! 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.
Conbinatorica
package. You can generate the permutations one at a time to score using its functions. $\endgroup$Permutations
will blow up the memory. $\endgroup$