- At any point of time, each activity must have exactly 12 people
- For each person, the list of activities must not be repeated and should cover all the activities
create given number of unique permutations
5 views (last 30 days)
Show older comments
I am preparing a speed-dating type work event where people will be placed into one of five groups to work together for 10mins, then I'll ring a bell and they'll move to a different group activity. All participants will have a card showing them the order that they should move through the activities [e.g., a participant with the card '5, 2, 3, 1, 4' would engage in activity 5 first, and then move to activity 2, etc until they finish on activity 4]. I'm trying to generate these cards for all participants so that everyone has a unique journey through the five activities.
I need:
- Everyone to attend each activity once only
- The number of people in each group at one time to be closely matched (don't want loads of people arriving at the same activity at once, while others are relatively empty)
- Every participant to have a unique order of attending groups
The following code gives me 120 unique ways that a participants can move through the 5 activities. If used this list to make the cards, there would always be 24 people engaging with each activity so the group sizes would be perfectly matched and no two people would have the exact same experience - great!
activities = [1,2,3,4,5];
P = perms(activities)
However, I am only expecting 60 people! I want to cut this list down so that I have 12 people engaging in each activity at a time. If I simply cut this list in half, I lose the balance of people in the different groups. Is there any easy way to cut this to 60 unique permutations with the restriction that I need to balance across the positions?
2 Comments
Madheswaran
on 4 Sep 2024
Hi Rachael,
If your constraints are
Then I suggest this below code without using 'perm' function.
The idea behind the code is simple, divide the 60 people into 5 different batches. For the first activity, allocate the batch 1 to activity 1, batch-2 to activity-2, and so on. For the second activity, cycle the batches onto the next set of activities as explained in the code.
num_people = 60;
num_activities = 5;
cards = zeros(num_people, num_activities); % 60 * 5
batch1 = 1:12;
batch2 = 13:24;
batch3 = 25:36;
batch4 = 37:48;
batch5 = 49:60;
for activity_i = 1:5
cards(batch1, activity_i) = mod(activity_i + 0, num_activities);
cards(batch2, activity_i) = mod(activity_i + 1, num_activities);
cards(batch3, activity_i) = mod(activity_i + 2, num_activities);
cards(batch4, activity_i) = mod(activity_i + 3, num_activities);
cards(batch5, activity_i) = mod(activity_i + 4, num_activities);
end
% replace zeros with 5
cards(cards == 0) = 5;
You can shuffle the cards while delivering it to the participants for the effect of randomness.
Accepted Answer
Rachael
on 4 Sep 2024
2 Comments
John D'Errico
on 4 Sep 2024
Edited: John D'Errico
on 4 Sep 2024
ALWAYS be very careful with the AI tools, as too often they provide complete garbage, that seems vaguely correct. Test it. Verify it. But if you implicitly trust something just because a computer wrote it, you get what you paid for.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!