I have generated a sample dataset of 1000 people with their available timeslots during the day. Each timeslot is a 30 minute interval during the day. 0 indicates they are free during that timeslot and 1 indicates they are busy.
for example:
| Time | Sally | Mark | Nish |
| ------------| ----- | ---- | ---- |
| 0900 - 0930 | 0 | 1 | 1 |
| 0930 - 1000 | 1 | 0 | 1 |
| 1000 - 1030 | 1 | 1 | 1 |
| 1030 - 1100 | 1 | 0 | 1 |
| 1100 - 1130 | 0 | 1 | 1 |
| 1200 - 1230 | 1 | 0 | 0 |
I want to create the maximum number of groups of 5 people that have at least one available timeslot in common. Each group should be mutually exclusive. I want to maximize the number of successful groups that are created.
At present, I am using a pretty crude algorithm. I sample the dataset for 5 people then check if they have an available timeslot in common. If they do, then I remove them from the dataset and repeat the process. If they do not have a common timeslot available, I resample another 5 people and keep trying until I find a sample of 5 with a common timeslot. If after a 1000 resamples, it is unable to find a sample of 5 that meets the criteria it stops.
This seems very inefficient to me and I was wondering if there is a better way to do this.