Add Team functions

This commit is contained in:
2025-09-22 12:53:46 -04:00
parent 3daa3b81b3
commit dc83a18d76
48 changed files with 2364 additions and 633 deletions
+32
View File
@@ -0,0 +1,32 @@
using Core.Entities;
namespace Core.Calculation;
public class TeamSchedulerSolution(
Team[][] timeSlots,
string status)
{
public Team[][] TimeSlots { get; set; } = timeSlots;
public string Status { get; set; } = status;
public static int GetStudentTeamOverlapCount(Team[][] timeSlots)
{
return timeSlots.Sum(GetStudentTeamOverlapCount);
}
private static int GetStudentTeamOverlapCount(Team[] timeSlot)
{
return GetStudentTeamOverlaps(timeSlot).Count();
}
public static IEnumerable<Tuple<Student, IEnumerable<Team>>> GetStudentTeamOverlaps(Team[] timeSlot)
{
return
from s in timeSlot.SelectMany(ts => ts.Students).Distinct()
group s by timeSlot.Where(t => t.Students.Contains(s))
into gs
where gs.Key.Count() > 1
select Tuple.Create(gs.First(), gs.Key);
}
}