Here is a rough attempt at what you are asking for. I think it will work. I assume, others in the Community will have a better idea It uses 2 sample data tables, and assigns the clips to review from them
Names Default To Here( 1 );
dtRev = New Table( "Reviewers",
New Column( "Reviewer", character, values( {"400180174", "400197965", "400241556", "400244169", "400247301", "400258583"} ) )
);
dtClp = New Table( "Clips",
New Column( "Clip",
character,
values(
{"GI2C328162023S24", "SQBC107132043S11", "SQBC107132023S11", "GI2C318162023S24",
"GI2C308162023S24", "SQBC107133023S11","GI2C308162022S25", "SQBC107132022S12",
"SQBC107132022S13", "GI2C309162032S24", "GI2C308162022S27", "SQBC107132022S16"}
)
)
);
// Create a new reviewers data table with each reviewer having 6 entries
dtRev6 = dtRev << concatenate( dtRev, dtRev, dtRev,dtRev,dtRev );
// Randomize the order of reviewer
dtRev6 << New Column( "random", set each value( Random Uniform( 1, 1000000 ) ) );
dtRev6 << Sort( By( :random ), Replace Table, Order( Ascending ) );
dtRev6 << delete columns( random );
// Scan through data table making sure the same name does not appear within 3 of the previous
// time it appeared
For( i = 6, i <= N Rows( dtRev6 ), i++,
If( :Reviewer[i] == :Reviewer[i - 1] | Try( :Reviewer[i] == :Reviewer[i - 2], 0 ),
For( k = i + 1, k <= N Rows( dtRev6 ), k++,
If( :Reviewer[k] != :Reviewer[i] & :Reviewer[k] != :Reviewer[i - 1] & Try( :Reviewer[k] != :Reviewer[i - 1], 1 ),
hold = :Reviewer[i];
:Reviewer[i] = :Reviewer[k];
:Reviewer[k] = hold;
Break();
)
)
)
);
// Assign clips
dtRev6 << New Column( "Clip", character );
For( i = 1, i <= nrows(dtClp), i++,
If( (i-1) * 3 +1 <= N Rows( dtRev6 ),
For( k = (i-1) * 3 +1, k <= (i-1) * 3 +3, k++,
dtRev6:Clip[k] = dtClp:Clip[i];
)
)
);
// Sort the table so reviewer's clips are listed together
dtRev6 << Sort(
By( :Reviewer ),
Replace Table,
Order( Ascending )
);
Jim