/**
 * You are a Veterinarian and you have a map representing different animals and their ages in months.
 * Your task is to find the animal with the oldest age and return its name.
 *
 * @param animalMap A map containing animal names as keys and their ages in months as values.
 * @return The name of the animal with the oldest age.
 *
 * Example:
 * checkAnimalAge(mapOf("dog" to 36, "cat" to 24, "rabbit" to 42)) // Output: "rabbit"
 */
fun checkAnimalAge(animalMap: Map<String, Int>): String {

    if (animalMap !is Map<*, *>) {
        return "Invalid input! Please provide a map."
    }

    var oldestAge: Int? = null
    var oldestAnimal: String? = null

    // Complete the code to find the animal with the oldest age
    for ((animal, age) in animalMap) {
        if (oldestAge == null || age > oldestAge) {
            oldestAge = age
            oldestAnimal = animal
        }
    }

    return oldestAnimal ?: ""
}
/**
 * You are a Veterinarian and you have a map representing different animals and their ages in months.
 * Your task is to find the animal with the oldest age and return its name.
 *
 * @param animalMap A map containing animal names as keys and their ages in months as values.
 * @return The name of the animal with the oldest age.
 *
 * Example:
 * checkAnimalAge(mapOf("dog" to 36, "cat" to 24, "rabbit" to 42)) // Output: "rabbit"
 */
fun checkAnimalAge(animalMap: Map<String, Int>): String {
/**
 * You are a Veterinarian and you have a map representing different animals and their ages in months.
 * Your task is to find the animal with the oldest age and return its name.
 *
 * @param animalMap A map containing animal names as keys and their ages in months as values.
 * @return The name of the animal with the oldest age.
 *
 * Example:
 * checkAnimalAge(mapOf("dog" to 36, "cat" to 24, "rabbit" to 42)) // Output: "rabbit"
 */
fun checkAnimalAge(animalMap: Map<String, Int>): String {

    if (animalMap !is Map<*, *>) {
        return "Invalid input! Please provide a map."
    }

    var oldestAge: Int? = null
    var oldestAnimal: String? = null

    // Complete the code to find the animal with the oldest age
    for ((animal, age) in animalMap) {
        if (oldestAge == null || age > oldestAge) {
            oldestAge = age
            oldestAnimal = animal
        }
    }

    return oldestAnimal ?: ""
}