❔ ✅ Semi-Random-Generator
So I'm trying to generate a list for scheduling people to a task.
What I intend is to generate the list in such a way that each person is combined with one other person and gets either one of three tasks,
I want the people to be combined with another in such a way that for a complete iteration of the people, everyone gets paired with another person once and they get each of the three tasks in a repeating order.
Group 1: PersonA + PersonB => Task_1 || Person C + PersonD => Task_2 || PersonE => Task_3
Next iteration it should be a version of this where no person is paired with the same person twice, untill all persons have had all three tasks once. Then repeat the gesture
yes there are only 5 people to choose from and three tasks. That is a fixed amount
Help?14 Replies
what have you tried so far?
Basically create an array of people, and an array of tasks, and do a random number between 0 and 4 (or 0 and 2 for the tasks) and create a dictionary with those items. But that doesn't follow the rules.
And from here I'm not really sure where to start
I'd start with figuring out how to find pairs of people, that seems to be where you're having issues. Maybe think of just ordering the queue of people such that indexes help map to tasks:
does that make sense?
I'm not sure I follow entirely...
Yes I was stuck mostly on paring people, regardless of tasks.
And I wanted to figure some algorithm where
people[x]
+ people[y]
would always be.. hrm..
people[x] + people[y]
is the same as people[y] + people[x]
each person would be paired with each other person once and only once
from there it would pair these groups with tasks
but since there are only 5 people, it would make a group of 2 + 2 + 1
so task_1 = 2 people, task_2 = 2 people, and task_3 = free, so 1 personcorrect, people[x] + people[y] would always be the same as the inverse
but the crux is that I always have to have a person alone in a group too 😅
So hard-coded it should look something like this but then I'd need it randomized sorta I guess?:
and then randomized I'd need to appoint the tasks too 😅
do you need it randomized, or do you need to find all combinations possible?
Sorry wasn't done yet
The idea behind this is that I have a list of "dates"
And for each of these dates I have three tasks, let's call em groceries, dishwashing, and lazy
(lazy just means the one single person is free of tasks at that date)
now I want each date to have a random group do one task, another random group does task 2, and a single person is free of tasks
A group can never do the same task twice in a row, and this group cannot do the other task the same time as they do the first task.
So it would be
group_1 does task_1, group_2 does task_2, and single_person_group does nothing
this same configuration cannot happen twice in a single repeat
so I cannot have
date 1:the eventual result will repeat forever until there are no more dates So I think find all combinations possible? I mean in an excel I can probably just manually do it, but it would be so much better in this way, because in an excel doing it manually would make me biassed?group_1 does task_1, group_2 does task_2, and single_person_group does nothing
date 2:group_3 does task_1, group_4 does task_2, and single_person_group does nothing
date 3:group_5 does task_1, group_6 does task_2, and single_person_group does nothing
date 4:group_7 does task_1, group_8 does task_2, and single_person_group does nothing
.....
gotcha, in that case I'd start with randomizing the list of people then given that randomized set find all pairs (can be hardcoded or done at runtime)
also I just noticed, my example is flawed, I missed the "wrong" example in there 😅
if you want to do the pairs programmatically it's still the same thing, you just remove the hardcoding and calculate them.
I'm not sure I follow you here..
I mean, I think very literal I have this:
but this only makes three groups for each of the combinations I guess?
but then I need to make sure I remove any duplicates for a single "repetition" I guess
also,
Sched
is simply an enum
but I'd like to do this programatically if I'm even on the right track 😅Sorry, I went out for the rest of the day (it was weekend for me). You're somewhat on the right track. To get programmatic for an enum you can do
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.