/**
 * In this exercise, you need to write a function that takes in the list
 * of animals treated by two different veterinarians and finds out the
 * common animals treated by both veterinarians.
 *
 * The veterinarians are represented as pairs, where the first element
 * is the veterinarian's name and the second element is the list of
 * animals treated by that veterinarian.
 *
 * Your task is to implement the 'findCommonAnimals' function which
 * accepts two veterinarian pairs as arguments and returns a list
 * containing the common animals treated by both veterinarians.
 *
 * Example:
 * val vet1 = Pair("Dr. Smith", listOf("Dog", "Cat", "Bird", "Rabbit"))
 * val vet2 = Pair("Dr. Johnson", listOf("Rabbit", "Bird", "Turtle", "Hamster"))
 *
 * findCommonAnimals(vet1, vet2)
 * Output: ['Bird', 'Rabbit']
 */
fun findCommonAnimals(vet1: Pair<String, List<String>>, vet2: Pair<String, List<String>>): List<String> {

    val vet1Animals = vet1.second.toSet()
    val vet2Animals = vet2.second.toSet()

    val commonAnimals = vet1Animals.intersect(vet2Animals).toList()

    return commonAnimals
}
/**
 * In this exercise, you need to write a function that takes in the list
 * of animals treated by two different veterinarians and finds out the
 * common animals treated by both veterinarians.
 *
 * The veterinarians are represented as pairs, where the first element
 * is the veterinarian's name and the second element is the list of
 * animals treated by that veterinarian.
 *
 * Your task is to implement the 'findCommonAnimals' function which
 * accepts two veterinarian pairs as arguments and returns a list
 * containing the common animals treated by both veterinarians.
 *
 * Example:
 * val vet1 = Pair("Dr. Smith", listOf("Dog", "Cat", "Bird", "Rabbit"))
 * val vet2 = Pair("Dr. Johnson", listOf("Rabbit", "Bird", "Turtle", "Hamster"))
 *
 * findCommonAnimals(vet1, vet2)
 * Output: ['Bird', 'Rabbit']
 */
fun findCommonAnimals(vet1: Pair<String, List<String>>, vet2: Pair<String, List<String>>): List<String> {
/**
 * In this exercise, you need to write a function that takes in the list
 * of animals treated by two different veterinarians and finds out the
 * common animals treated by both veterinarians.
 *
 * The veterinarians are represented as pairs, where the first element
 * is the veterinarian's name and the second element is the list of
 * animals treated by that veterinarian.
 *
 * Your task is to implement the 'findCommonAnimals' function which
 * accepts two veterinarian pairs as arguments and returns a list
 * containing the common animals treated by both veterinarians.
 *
 * Example:
 * val vet1 = Pair("Dr. Smith", listOf("Dog", "Cat", "Bird", "Rabbit"))
 * val vet2 = Pair("Dr. Johnson", listOf("Rabbit", "Bird", "Turtle", "Hamster"))
 *
 * findCommonAnimals(vet1, vet2)
 * Output: ['Bird', 'Rabbit']
 */
fun findCommonAnimals(vet1: Pair<String, List<String>>, vet2: Pair<String, List<String>>): List<String> {

    val vet1Animals = vet1.second.toSet()
    val vet2Animals = vet2.second.toSet()

    val commonAnimals = vet1Animals.intersect(vet2Animals).toList()

    return commonAnimals
}