public IReadOnlyCollection <TeamSet> MostProductiveTeamSets() { List <TeamSet> teams = AllTeamSets(); teams.Sort(new TeamSetComparer()); TeamSet first = teams.First(); return(teams .TakeWhile(ts => ts.TotalProductivity == first.TotalProductivity) .ToArray()); }
private void FourthTeamAction(LinkedList <Team> currentTeams, List <TeamSet> teamSets, LinkedList <int> usedLayers, LinkedList <int> usedEconomists, LinkedList <int> usedEngineers, LinkedList <int> usedProgrammers, int lawyer, int economist, int engineer, int programmer) { Team team = _computer.GetTeam(3, lawyer, economist, engineer, programmer); if (team == null) { return; } currentTeams.AddLast(team); var newTeamSet = new TeamSet { Teams = currentTeams.ToList(), TotalProductivity = currentTeams.Sum(t => t.Productivity) }; teamSets.Add(newTeamSet); currentTeams.RemoveLast(); }