I have a number of samples and want to pick a random subset of those of a defined length and repeat this process until every samples occurs 3 times, no sample occurring twice in a given row.

For example:

```
samples=range(12)
l=6
repeats=3

```

I expect 6 rows of 6 samples.
I would like to have something like:

```
[1, 2, 11, 7, 0, 3]
[2, 5, 0, 7, 10, 3]
[11, 0, 8, 7, 6, 1]
[4, 11, 5, 9, 3, 6]
[4, 9, 8, 1, 10, 2]
[9, 5, 6, 4, 8, 10]

```

I tried the following but it only worked in one case (by chance) when the samples were picked equally, I usually get

```none
ValueError: sample larger than population

```

Code:

```
import random
samples=range(12)
measured={key:0 for key in samples}
while len(samples)>0:
    sample=random.sample(samples,6)
    print sample
    for s in sample:
        measured[s]+=1
        if measured[s]==3:
            samples.remove(s)

```

I was wondering if there is a way to tweek `numpy.random.choice` or from `itertools.permutations` but those didn't work because of the constrains above.

Is there a sample way I am overlooking or do I need to work with nested loops/ifs?