What code can I use if I have ten numbers and I want to produce 1000 different randomly shuffled orders of the the ten numbers
<p>I can use this to find all of the possible options, however, I want a random sample of 1000 from this set:</p>

<pre><code>items = range(1,11)
//from itertools import permutations
//for p in permutations(items):
print(p)
</code></pre>

<p>Since <code>set</code> guarantees the uniqueness of its elements, you can generate permutations via <code>random.sample()</code> and attempt adding the result until the size of the set gets up to the desired quantity:</p>

<pre><code>import random

a = range(1,11)
solutions = set()
while len(solutions) &lt; 1000:
    solutions.add(tuple(random.sample(a, 10)))
</code></pre>

<p>At this point <code>solutions</code> contains a set of tuples which are unique permutations. A variation on the theme uses shuffling rather than sampling:</p>

<pre><code>import random

a = list(range(1,11))
solutions = set()
while len(solutions) &lt; 1000:
    random.shuffle(a)
    solutions.add(tuple(a))
</code></pre>

<p>If you want a list of lists rather than a set of tuples, append the following after the <code>while</code> loop:</p>

<pre><code>lols = [list(x) for x in solutions]
</code></pre>

<p>Given that you want 1000 out of the 10! (which is 3628800) permutations, the risk of collisions is close to zero.  The expected number of iterations of the loop is 1000 plus a small fraction, less than 1001.</p>

python random permutation shuffle sample