Let l
be a list
l = Flatten[Range[7] & /@ Range[12]]; (* 1,2,3,4,5,6,7,1,2,3,4,5,6,7,... *)
The question is to efficiently generate three random permutations from this list, like
p1 = RandomSample[l];
p2 = RandomSample[l];
p3 = RandomSample[l];
but with a very special property. The three lists may not have an equal value on the same position. In other words: every element of Transpose[{p1,p2,p3}]
must have three unique values.
p := Array[RandomSample[l] &, 3];p //. h : {{__} ..} /; Times @@ (Tr /@ Abs /@ Differences /@ Transpose@h) == 0 :> p
$\endgroup$