/**
 * Given a nested tuple containing the performances of an athlete in different divisions,
 * return the average score of the athlete for the provided division.
 *
 * @param athlete Nested tuple representing the athlete's performances in different divisions.
 * @param division Division name for which average score needs to be calculated.
 * @return Average score of the athlete for the provided division.
 *
 * Example:
 * performance = listOf(("Division A", 9.5), ("Division B", 8.7), ("Division C", 9.1), ("Division A", 8.9))
 * divisionNestedTuples(performance, "Division A") // 9.2
 * divisionNestedTuples(performance, "Division C") // 9.1
 */
fun divisionNestedTuples(athlete: List<Pair<String, Double>>, division: String): Double {

    var totalScore = 0.0
    var count = 0

    for (perf in athlete) {
        if (perf.first == division) {
            totalScore += perf.second
            count++
        }
    }

    return totalScore / count
}
/**
 * Given a nested tuple containing the performances of an athlete in different divisions,
 * return the average score of the athlete for the provided division.
 *
 * @param athlete Nested tuple representing the athlete's performances in different divisions.
 * @param division Division name for which average score needs to be calculated.
 * @return Average score of the athlete for the provided division.
 *
 * Example:
 * performance = listOf(("Division A", 9.5), ("Division B", 8.7), ("Division C", 9.1), ("Division A", 8.9))
 * divisionNestedTuples(performance, "Division A") // 9.2
 * divisionNestedTuples(performance, "Division C") // 9.1
 */
fun divisionNestedTuples(athlete: List<Pair<String, Double>>, division: String): Double {
/**
 * Given a nested tuple containing the performances of an athlete in different divisions,
 * return the average score of the athlete for the provided division.
 *
 * @param athlete Nested tuple representing the athlete's performances in different divisions.
 * @param division Division name for which average score needs to be calculated.
 * @return Average score of the athlete for the provided division.
 *
 * Example:
 * performance = listOf(("Division A", 9.5), ("Division B", 8.7), ("Division C", 9.1), ("Division A", 8.9))
 * divisionNestedTuples(performance, "Division A") // 9.2
 * divisionNestedTuples(performance, "Division C") // 9.1
 */
fun divisionNestedTuples(athlete: List<Pair<String, Double>>, division: String): Double {

    var totalScore = 0.0
    var count = 0

    for (perf in athlete) {
        if (perf.first == division) {
            totalScore += perf.second
            count++
        }
    }

    return totalScore / count
}