Create many constrained, random permutation of a list
        Posted  
        
            by Eyal
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Eyal
        
        
        
        Published on 2008-09-18T15:00:27Z
        Indexed on 
            2010/05/02
            0:47 UTC
        
        
        Read the original article
        Hit count: 650
        
I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the number of times each elements is used is the same (or as close as possible). For instance, if my elements are 0,1,2,3, y is 6, and z is 2, then one possible solution is:
0,3 1,2 3,0 2,1 0,1 2,3
Each row has only unique elements and no element has been used more than 3 times. If y were 7, then 2 elements would be used 4 times, the rest 3.
© Stack Overflow or respective owner