/**
 * Given a nested dictionary representing the temperature measurements of patients, this function calculates the average temperature of all patients.
 *
 * @param patientData A nested dictionary with patient IDs as keys and tuple of temperature recordings as values.
 * @return The average temperature of all patients.
 * @throws IllegalArgumentException If the patientData dictionary is empty.
 */
fun calculateAverageTemperature(patientData: Map<String, List<Double>>): Double {

    if (patientData.isEmpty()) {
        throw IllegalArgumentException("The patientData dictionary is empty.")
    }

    var totalTemperature = 0.0
    var numMeasurements = 0

    for ((_, measurements) in patientData) {
        for (measurement in measurements) {
            if (measurement is Double) {
                totalTemperature += measurement
                numMeasurements++
            }
        }
    }

    return totalTemperature / numMeasurements
}
/**
 * Given a nested dictionary representing the temperature measurements of patients, this function calculates the average temperature of all patients.
 *
 * @param patientData A nested dictionary with patient IDs as keys and tuple of temperature recordings as values.
 * @return The average temperature of all patients.
 * @throws IllegalArgumentException If the patientData dictionary is empty.
 */
fun calculateAverageTemperature(patientData: Map<String, List<Double>>): Double {
/**
 * Given a nested dictionary representing the temperature measurements of patients, this function calculates the average temperature of all patients.
 *
 * @param patientData A nested dictionary with patient IDs as keys and tuple of temperature recordings as values.
 * @return The average temperature of all patients.
 * @throws IllegalArgumentException If the patientData dictionary is empty.
 */
fun calculateAverageTemperature(patientData: Map<String, List<Double>>): Double {

    if (patientData.isEmpty()) {
        throw IllegalArgumentException("The patientData dictionary is empty.")
    }

    var totalTemperature = 0.0
    var numMeasurements = 0

    for ((_, measurements) in patientData) {
        for (measurement in measurements) {
            if (measurement is Double) {
                totalTemperature += measurement
                numMeasurements++
            }
        }
    }

    return totalTemperature / numMeasurements
}