/**
 * This function takes in a nested map of environmental data and a set of pollutants to remove.
 * It iterates over the map using nested loops, removes any areas that have pollutants above a certain threshold,
 * and returns the updated map.
 *
 * @param data The nested map representing environmental data
 * @param pollutants The set of pollutants to remove from the data
 * @return The updated map with polluted areas removed
 */
fun removePollutedAreas(data: MutableMap<String, MutableMap<String, MutableMap<String, Int>>>, pollutants: Set<String>): MutableMap<String, MutableMap<String, MutableMap<String, Int>>> {

    for ((region, areaData) in data) {
        for ((area, readings) in areaData) {
            for ((pollutant, value) in readings) {
                if (pollutant in pollutants && value > 50) {  // Arbitrary threshold, change as required
                    data[region]?.get(area)?.remove(pollutant)
                }
            }
        }
    }
    return data
}

// Sample usage
val data = mutableMapOf(
    "Region1" to mutableMapOf(
        "Area1" to mutableMapOf("PM2.5" to 40, "SO2" to 20),
        "Area2" to mutableMapOf("CO2" to 100, "NO2" to 60)
    ),
    "Region2" to mutableMapOf(
        "Area3" to mutableMapOf("PM2.5" to 60, "NO2" to 30)
    )
)

val pollutants = setOf("PM2.5", "NO2")
val updatedData = removePollutedAreas(data, pollutants)
/**
 * This function takes in a nested map of environmental data and a set of pollutants to remove.
 * It iterates over the map using nested loops, removes any areas that have pollutants above a certain threshold,
 * and returns the updated map.
 *
 * @param data The nested map representing environmental data
 * @param pollutants The set of pollutants to remove from the data
 * @return The updated map with polluted areas removed
 */
fun removePollutedAreas(data: MutableMap<String, MutableMap<String, MutableMap<String, Int>>>, pollutants: Set<String>): MutableMap<String, MutableMap<String, MutableMap<String, Int>>> {
/**
 * This function takes in a nested map of environmental data and a set of pollutants to remove.
 * It iterates over the map using nested loops, removes any areas that have pollutants above a certain threshold,
 * and returns the updated map.
 *
 * @param data The nested map representing environmental data
 * @param pollutants The set of pollutants to remove from the data
 * @return The updated map with polluted areas removed
 */
fun removePollutedAreas(data: MutableMap<String, MutableMap<String, MutableMap<String, Int>>>, pollutants: Set<String>): MutableMap<String, MutableMap<String, MutableMap<String, Int>>> {

    for ((region, areaData) in data) {
        for ((area, readings) in areaData) {
            for ((pollutant, value) in readings) {
                if (pollutant in pollutants && value > 50) {  // Arbitrary threshold, change as required
                    data[region]?.get(area)?.remove(pollutant)
                }
            }
        }
    }
    return data
}

// Sample usage
val data = mutableMapOf(
    "Region1" to mutableMapOf(
        "Area1" to mutableMapOf("PM2.5" to 40, "SO2" to 20),
        "Area2" to mutableMapOf("CO2" to 100, "NO2" to 60)
    ),
    "Region2" to mutableMapOf(
        "Area3" to mutableMapOf("PM2.5" to 60, "NO2" to 30)
    )
)

val pollutants = setOf("PM2.5", "NO2")
val updatedData = removePollutedAreas(data, pollutants)