Reputation: 73
I have a hash of teams and possible matchups and each matchup is scored. Team A could play against Team B, C, OR D and each matchup has a score ->
matches =
{
Team A => [{name: B, score: 8}, {name: C, score: 10}, {name: D,score: 9}],
Team B => [{name: A, score: 8}, {name: C, score: 7},{name: D,score: 7}],
Team C => [{name: A, score: 10}, {name: B, score: 7}, {name: D,score: 6}],
Team D => [{name: A, score: 9}, {name: B, score: 7}, {name: C,score: 6}]
}
I want to be able select only matchups where a team plays once. All that matters is that each matchup is above the minimum threshold So for example -> 7.
C -> A, D -> B would be acceptable
If all teams cannot be scheduled with the minimum scoring threshold. The threshold will be lowered and the process will start again. What are some possible way to approach this problem?
Currently how it's working -> grouping all possible matchups above the threshold by team (Similar to the snippet) And ordering the list of match groups by group length (Smallest - Largest). Matching the most constrained teams first.
Upvotes: 0
Views: 59