I am trying to form every unique possible set of teams, of different sizes, from a group of people. I have a list of people of size n and there are k teams. In the case below there are 13 people and 4 teams.
people = ["Bob", "Jane", "Mary", "Martha", "James", "Charles", "Kevin", "Debbie", "Brian", "Matt", "Milo", "Chris", "Sam"]
example output:
[[Bob, Jane, Mary], [Martha, James, Charles], [Kevin, Debbie, Brian], [Matt, Milo, Chris, Sam]]
[[Bob, Jane, Mary], [Martha, James, Charles], [Kevin, Debbie, Matt], [Brian, Milo, Chris, Sam]]
[[Bob, Jane, Mary], [Martha, James, Charles], [Kevin, Debbie, Milo], [Brain, Matt, Chris, Sam]]
[[Bob, Jane, Mary], [Martha, James, Charles], [Kevin, Debbie, Chris], [Brian, Matt, Milo, Sam]]
.
.
.
[[Bob, Jane, Mary], [Martha, James, Charles], [Kevin, Debbie, Brian, Matt], [Milo, Chris, Sam]]
.
.
.
Teams can be any size 3 - 5. I have seen similar versions of this problem but none with the addition that teams can vary in size. The result I'm hoping for is implemented in such a way that I can call a function that takes in the set of teams and returns an integer as a score for the team and keeps track of the team with the highest score.
ie:
def generate_best_teams(people, num_teams):
loop:
teams gets created
teams_score = calculate_score(teams)
if teams_score > best_score:
best_score = teams_score
best_teams = teams
return best_teams
Any help with this problem would be greatly apricated.