/**
 * A zoologist wants to create a census of different animal species in a region.
 *
 * You are given a list of tuples where each tuple consists of the animal species name and the count of individuals of
 * that species observed by the zoologist. Your task is to write a function that takes this list as input and returns
 * a dictionary where the keys are the animal species names and the values are the total counts of individuals observed.
 *
 * Example:
 * animalList = listOf(Pair("Lion", 3), Pair("Elephant", 5), Pair("Tiger", 2), Pair("Lion", 2), Pair("Tiger", 1))
 * getAnimalCensus(animalList) -> mapOf("Lion" to 5, "Elephant" to 5, "Tiger" to 3)
 */
fun getAnimalCensus(animalList: List<Pair<String, Int>>): Map<String, Int> {

    val animalCensus = mutableMapOf<String, Int>()
    for ((animal, count) in animalList) {
        animalCensus[animal] = animalCensus.getOrDefault(animal, 0) + count
    }
    return animalCensus
}
/**
 * A zoologist wants to create a census of different animal species in a region.
 *
 * You are given a list of tuples where each tuple consists of the animal species name and the count of individuals of
 * that species observed by the zoologist. Your task is to write a function that takes this list as input and returns
 * a dictionary where the keys are the animal species names and the values are the total counts of individuals observed.
 *
 * Example:
 * animalList = listOf(Pair("Lion", 3), Pair("Elephant", 5), Pair("Tiger", 2), Pair("Lion", 2), Pair("Tiger", 1))
 * getAnimalCensus(animalList) -> mapOf("Lion" to 5, "Elephant" to 5, "Tiger" to 3)
 */
fun getAnimalCensus(animalList: List<Pair<String, Int>>): Map<String, Int> {
/**
 * A zoologist wants to create a census of different animal species in a region.
 *
 * You are given a list of tuples where each tuple consists of the animal species name and the count of individuals of
 * that species observed by the zoologist. Your task is to write a function that takes this list as input and returns
 * a dictionary where the keys are the animal species names and the values are the total counts of individuals observed.
 *
 * Example:
 * animalList = listOf(Pair("Lion", 3), Pair("Elephant", 5), Pair("Tiger", 2), Pair("Lion", 2), Pair("Tiger", 1))
 * getAnimalCensus(animalList) -> mapOf("Lion" to 5, "Elephant" to 5, "Tiger" to 3)
 */
fun getAnimalCensus(animalList: List<Pair<String, Int>>): Map<String, Int> {

    val animalCensus = mutableMapOf<String, Int>()
    for ((animal, count) in animalList) {
        animalCensus[animal] = animalCensus.getOrDefault(animal, 0) + count
    }
    return animalCensus
}