<commit_before>package assigner

class InitialMatching(students: Map[Int, Student], groups: Map[Int, Group]) extends Assignment(null, null) {
  private val totalSize = groups.values.map(_.maxSize).sum
  private val mandatoryStudentIds = students.values.filter(_.mandatory).map(_.id)
  private val otherStudentIds = students.values.filter(!_.mandatory).map(_.id).toList.shuffle
  private val numOfOtherStudents = totalSize - mandatoryStudentIds.size
  private val orderedStudentIds =
    (mandatoryStudentIds ++ otherStudentIds.take(numOfOtherStudents)).toList.shuffle ++
      otherStudentIds.drop(numOfOtherStudents)

  private val currentGroupSizes = Array.fill(groups.size)(0)
  studentMap = orderedStudentIds.map { studentId =>
    val student = students(studentId)
    var finished = false
    var groupId = -1

    val prefs = student.preferences ++ groups.keySet.diff(student.preferences.toSet).toList.shuffle

    for {
      preference <- prefs
      if currentGroupSizes(preference) < groups(preference).maxSize && !finished
    } {
      currentGroupSizes(preference) += 1
      finished = true
      groupId = preference
    }
<commit_msg>I did awesome bugfix shit...<commit_after>package assigner

class InitialMatching(students: Map[Int, Student], groups: Map[Int, Group]) extends Assignment(null, null) {
  private val totalSize = groups.values.map(_.maxSize).sum
  private val mandatoryStudentIds = students.values.filter(_.mandatory).map(_.id)
  private val otherStudentIds = students.values.filter(!_.mandatory).map(_.id).toList.shuffle
  private val numOfOtherStudents = totalSize - mandatoryStudentIds.size
  private val orderedStudentIds =
    (mandatoryStudentIds ++ otherStudentIds.take(numOfOtherStudents)).toList.shuffle ++
      otherStudentIds.drop(numOfOtherStudents)

  private val currentGroupSizes = collection.mutable.Map(groups.keys.map(_ -> 0).toSeq: _*)
  studentMap = orderedStudentIds.map { studentId =>
    val student = students(studentId)
    var finished = false
    var groupId = -1

    val prefs = student.preferences ++ groups.keySet.diff(student.preferences.toSet).toList.shuffle

    for {
      preference <- prefs
      if currentGroupSizes(preference) < groups(preference).maxSize && !finished
    } {
      currentGroupSizes(preference) += 1
      finished = true
      groupId = preference
    }

{'fraction_non_alphanumeric': 0.10391822827938671, 'fraction_numerical': 0.002555366269165247, 'mean_word_length': 4.23162583518931, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '519738', 'n_tokens_mistral': 682, 'n_tokens_neox': 671, 'n_words': 141}