/**
 * Given a list of students and their grades, calculate the average score for each student.
 *
 * @param students List of strings representing the names of the students
 * @param grades Nested list of integers representing the grades for each student
 * @return avgScores Dictionary with each student's name as key and their average score as value
 */
fun calculateAverageScore(students: List<String>, grades: List<List<Int?>>): Map<String, Double?> {

    val avgScores = mutableMapOf<String, Double?>()
    for (i in students.indices) {
        var totalScore = 0
        var numGrades = 0
        for (j in grades[i].indices) {
            grades[i][j]?.let {
                totalScore += it
                numGrades++
            }
        }
        avgScores[students[i]] = if (numGrades != 0) totalScore.toDouble() / numGrades else null
    }
    return avgScores
}
/**
 * Given a list of students and their grades, calculate the average score for each student.
 *
 * @param students List of strings representing the names of the students
 * @param grades Nested list of integers representing the grades for each student
 * @return avgScores Dictionary with each student's name as key and their average score as value
 */
fun calculateAverageScore(students: List<String>, grades: List<List<Int?>>): Map<String, Double?> {
/**
 * Given a list of students and their grades, calculate the average score for each student.
 *
 * @param students List of strings representing the names of the students
 * @param grades Nested list of integers representing the grades for each student
 * @return avgScores Dictionary with each student's name as key and their average score as value
 */
fun calculateAverageScore(students: List<String>, grades: List<List<Int?>>): Map<String, Double?> {

    val avgScores = mutableMapOf<String, Double?>()
    for (i in students.indices) {
        var totalScore = 0
        var numGrades = 0
        for (j in grades[i].indices) {
            grades[i][j]?.let {
                totalScore += it
                numGrades++
            }
        }
        avgScores[students[i]] = if (numGrades != 0) totalScore.toDouble() / numGrades else null
    }
    return avgScores
}