/**
 * Given two farmers, find the animals that exist in both farmers' farms.
 *
 * @param farmer1 A map representing the animals in farmer 1's farm.
 * @param farmer2 A map representing the animals in farmer 2's farm.
 * @return A list of animals that exist in both farmers' farms.
 */
fun findIntersection(farmer1: Map<String, Int>, farmer2: Map<String, Int>): List<String> {

    // Initialize an empty list to store the intersection
    val intersection = mutableListOf<String>()

    // Iterate through each animal type in farmer 1's farm
    for (animal in farmer1.keys) {
        // Check if the animal exists in farmer 2's farm
        if (farmer2.containsKey(animal)) {
            // Add the animal to the intersection list
            intersection.add(animal)
        }
    }

    return intersection
}
/**
 * Given two farmers, find the animals that exist in both farmers' farms.
 *
 * @param farmer1 A map representing the animals in farmer 1's farm.
 * @param farmer2 A map representing the animals in farmer 2's farm.
 * @return A list of animals that exist in both farmers' farms.
 */
fun findIntersection(farmer1: Map<String, Int>, farmer2: Map<String, Int>): List<String> {
/**
 * Given two farmers, find the animals that exist in both farmers' farms.
 *
 * @param farmer1 A map representing the animals in farmer 1's farm.
 * @param farmer2 A map representing the animals in farmer 2's farm.
 * @return A list of animals that exist in both farmers' farms.
 */
fun findIntersection(farmer1: Map<String, Int>, farmer2: Map<String, Int>): List<String> {

    // Initialize an empty list to store the intersection
    val intersection = mutableListOf<String>()

    // Iterate through each animal type in farmer 1's farm
    for (animal in farmer1.keys) {
        // Check if the animal exists in farmer 2's farm
        if (farmer2.containsKey(animal)) {
            // Add the animal to the intersection list
            intersection.add(animal)
        }
    }

    return intersection
}