/**
 * Given a list of pairs representing temperature readings at different locations,
 * calculate the average temperature for each location.
 *
 * @param data A list of pairs in the form of (location, temperature).
 * @return A map mapping each location to its average temperature.
 */
fun calculateAverageTemperature(data: List<Pair<String, Double>>): Map<String, Double> {

    val locationTemperatures = mutableMapOf<String, MutableList<Double>>()
    for ((location, temperature) in data) {
        if (location !in locationTemperatures) {
            locationTemperatures[location] = mutableListOf()
        }
        locationTemperatures[location]!!.add(temperature)
    }

    val averageTemperatures = mutableMapOf<String, Double>()
    for ((location, temperatures) in locationTemperatures) {
        averageTemperatures[location] = temperatures.sum() / temperatures.size
    }

    return averageTemperatures
}
/**
 * Given a list of pairs representing temperature readings at different locations,
 * calculate the average temperature for each location.
 *
 * @param data A list of pairs in the form of (location, temperature).
 * @return A map mapping each location to its average temperature.
 */
fun calculateAverageTemperature(data: List<Pair<String, Double>>): Map<String, Double> {
/**
 * Given a list of pairs representing temperature readings at different locations,
 * calculate the average temperature for each location.
 *
 * @param data A list of pairs in the form of (location, temperature).
 * @return A map mapping each location to its average temperature.
 */
fun calculateAverageTemperature(data: List<Pair<String, Double>>): Map<String, Double> {

    val locationTemperatures = mutableMapOf<String, MutableList<Double>>()
    for ((location, temperature) in data) {
        if (location !in locationTemperatures) {
            locationTemperatures[location] = mutableListOf()
        }
        locationTemperatures[location]!!.add(temperature)
    }

    val averageTemperatures = mutableMapOf<String, Double>()
    for ((location, temperatures) in locationTemperatures) {
        averageTemperatures[location] = temperatures.sum() / temperatures.size
    }

    return averageTemperatures
}