Feb-03-2022, 10:56 PM
(This post was last modified: Feb-03-2022, 10:56 PM by deanhystad.)
Create a list of tuples for all possible combinations of row and col. Shuffle the list or randomly remove combinations from the list. This example shuffles the fields list and pops the combinations off the end.
from numpy import zeros, sum import random import itertools N = 25 # number of people A = 10 # length of field B = 10 # width of field D = 3 # columns for directory directory = zeros((N,D),float) # Create an entry for each row/column combination fields = list(itertools.product(range(A), range(B))) random.shuffle(fields) for i in range(N): directory[i,0] = i directory[i,1], directory[i,2] = fields.pop() print(directory)