/**
 * This function calculates the average score of each patient and returns a map containing the patient's name as key and their average score as value.
 *
 * @param patients A map where each key represents the patient's name and the corresponding value is a list of scores assigned to the patient.
 * @return A map containing the patient's name as key and their average score as value.
 */
fun calculatePatientScores(patients: Map<String, List<Int>>): Map<String, Double> {

    val avgScores = mutableMapOf<String, Double>()

    for ((patient, scores) in patients) {
        var sumScores = 0
        var numScores = 0

        for (score in scores) {
            sumScores += score // Summing up the scores
            numScores++ // Counting the number of scores

            if (sumScores >= 100) { // Checking if the sum of scores exceeds or equals 100
                avgScores[patient] = sumScores.toDouble() / numScores // Calculating average score
                break // Exiting the inner loop
            }

            if (scores.size - numScores == 0) { // Checking if all scores have been considered
                avgScores[patient] = sumScores.toDouble() / numScores // Calculating average score
            }
        }
    }

    return avgScores
}
/**
 * This function calculates the average score of each patient and returns a map containing the patient's name as key and their average score as value.
 *
 * @param patients A map where each key represents the patient's name and the corresponding value is a list of scores assigned to the patient.
 * @return A map containing the patient's name as key and their average score as value.
 */
fun calculatePatientScores(patients: Map<String, List<Int>>): Map<String, Double> {
/**
 * This function calculates the average score of each patient and returns a map containing the patient's name as key and their average score as value.
 *
 * @param patients A map where each key represents the patient's name and the corresponding value is a list of scores assigned to the patient.
 * @return A map containing the patient's name as key and their average score as value.
 */
fun calculatePatientScores(patients: Map<String, List<Int>>): Map<String, Double> {

    val avgScores = mutableMapOf<String, Double>()

    for ((patient, scores) in patients) {
        var sumScores = 0
        var numScores = 0

        for (score in scores) {
            sumScores += score // Summing up the scores
            numScores++ // Counting the number of scores

            if (sumScores >= 100) { // Checking if the sum of scores exceeds or equals 100
                avgScores[patient] = sumScores.toDouble() / numScores // Calculating average score
                break // Exiting the inner loop
            }

            if (scores.size - numScores == 0) { // Checking if all scores have been considered
                avgScores[patient] = sumScores.toDouble() / numScores // Calculating average score
            }
        }
    }

    return avgScores
}