using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
private const int UniversityMatchScore = 40;
private const int DepartmentMatchScore = 30;
private const int GraduateMatchScore = 1000;
private const int CourseMatchScore = 10;
private const int NoStudentBonus = 20;
private const int ExamScoreFactor = 30;
private const int ExamScoreReductionFactor = 2;
public static void Main()
List<Mentor> mentors = GenerateDummyMentors(15);
Student student = new Student
TargetUniversities = new List<string> { "Koç" },
TargetDepartments = new List<string> { "Engineering", "Computer Science" },
var sortedMentors = GetMatchingMentors(student, mentors);
foreach (var mentor in sortedMentors)
Console.WriteLine($"{mentor.Item1.FullName} {mentor.Item1} - Score: {mentor.Item2}");
static List<(Mentor, double)> GetMatchingMentors(Student student, List<Mentor> mentors)
var result = new ConcurrentQueue<(Mentor, double)>();
Parallel.ForEach(mentors, mentor =>
if (student.IsGraduate && mentor.GraduatedBefore)
score += GraduateMatchScore;
if (student.TargetUniversities.Contains(mentor.University))
score += UniversityMatchScore;
if (student.TargetDepartments.Contains(mentor.Department))
score += DepartmentMatchScore;
double examScoreDiff = Math.Abs(student.AverageExamScore - mentor.ExamScore);
score += Math.Max(0, ExamScoreFactor - (ExamScoreReductionFactor * examScoreDiff));
if (student.AttendedCourse == mentor.AttendedCourse)
score += CourseMatchScore;
if (mentor.StudentCount == 0)
result.Enqueue((mentor, score));
return result.OrderByDescending(m => m.Item2).Select(m => m).ToList();
static List<Mentor> GenerateDummyMentors(int count)
Random rnd = new Random();
List<string> universities = new List<string> { "Boğaziçi ", "Anadolu", "ODTÜ", "Ege", "Arel", "Nişantaşı", "Koç", "Bilkent" };
List<string> departments = new List<string> { "Bilgisayar", "Tıp", "Matematik", "Tarih" };
List<string> names = new List<string> { "John Doe", "Jane Smith", "Alice Brown", "Bob Johnson", "Charlie White" };
return Enumerable.Range(0, count).Select(i => new Mentor
FullName = names[rnd.Next(names.Count)],
University = universities[rnd.Next(universities.Count)],
Department = departments[rnd.Next(departments.Count)],
ExamScore = rnd.Next(50, 100),
AttendedCourse = rnd.Next(0, 2) == 1,
GraduatedBefore = rnd.Next(0, 2) == 1,
StudentCount = rnd.Next(0, 6)
public List<string> TargetUniversities;
public List<string> TargetDepartments;
public double AverageExamScore;
public bool AttendedCourse;
public string University;
public string Department;
public bool AttendedCourse;
public bool GraduatedBefore;
public override string ToString()
return $"[{University}-{Department}-Net:{ExamScore}]";