/**
 * This function takes a list of animals and their corresponding population data as inputs.
 * It returns the count of endangered species based on the given criteria:
 * - Critically Endangered: population count less than 100
 * - Endangered: population count between 100 and 1000
 * - Vulnerable: population count between 1000 and 5000
 * - Not Endangered: population count greater than 5000
 *
 * @param animalList A list of animals
 * @param populationData A map containing animal names as keys and their population counts as values
 * @return The count of endangered species based on the given criteria
 */
fun countEndangeredSpecies(animalList: List<String>, populationData: Map<String, Int>): Int {

    var count = 0

    for (animal in animalList) {
        count += if (populationData[animal]!! < 100) 1 else 0
        count += if (populationData[animal]!! in 100..1000) 1 else 0
        count += if (populationData[animal]!! in 1000..5000) 1 else 0
    }

    return count
}

// Example
/**
 * This function takes a list of animals and their corresponding population data as inputs.
 * It returns the count of endangered species based on the given criteria:
 * - Critically Endangered: population count less than 100
 * - Endangered: population count between 100 and 1000
 * - Vulnerable: population count between 1000 and 5000
 * - Not Endangered: population count greater than 5000
 *
 * @param animalList A list of animals
 * @param populationData A map containing animal names as keys and their population counts as values
 * @return The count of endangered species based on the given criteria
 */
fun countEndangeredSpecies(animalList: List<String>, populationData: Map<String, Int>): Int {
/**
 * This function takes a list of animals and their corresponding population data as inputs.
 * It returns the count of endangered species based on the given criteria:
 * - Critically Endangered: population count less than 100
 * - Endangered: population count between 100 and 1000
 * - Vulnerable: population count between 1000 and 5000
 * - Not Endangered: population count greater than 5000
 *
 * @param animalList A list of animals
 * @param populationData A map containing animal names as keys and their population counts as values
 * @return The count of endangered species based on the given criteria
 */
fun countEndangeredSpecies(animalList: List<String>, populationData: Map<String, Int>): Int {

    var count = 0

    for (animal in animalList) {
        count += if (populationData[animal]!! < 100) 1 else 0
        count += if (populationData[animal]!! in 100..1000) 1 else 0
        count += if (populationData[animal]!! in 1000..5000) 1 else 0
    }

    return count
}

// Example