/**
 * Given two lists of animals present in two farms, this function returns the animals that are present in both farms.
 *
 * @param farm1 List of animals present in the first farm.
 * @param farm2 List of animals present in the second farm.
 * @return List of animals present in both farms.
 */
fun intersectFarms(farm1: List<String>, farm2: List<String>): List<String> {

    val intersectedFarm = mutableListOf<String>()
    var f1 = 0
    while (f1 < farm1.size) {
        var f2 = 0
        while (f2 < farm2.size) {
            if (farm1[f1] !in intersectedFarm && farm1[f1] == farm2[f2]) {
                intersectedFarm.add(farm1[f1])
            }
            f2++
        }
        f1++
    }
    return intersectedFarm
}
/**
 * Given two lists of animals present in two farms, this function returns the animals that are present in both farms.
 *
 * @param farm1 List of animals present in the first farm.
 * @param farm2 List of animals present in the second farm.
 * @return List of animals present in both farms.
 */
fun intersectFarms(farm1: List<String>, farm2: List<String>): List<String> {
/**
 * Given two lists of animals present in two farms, this function returns the animals that are present in both farms.
 *
 * @param farm1 List of animals present in the first farm.
 * @param farm2 List of animals present in the second farm.
 * @return List of animals present in both farms.
 */
fun intersectFarms(farm1: List<String>, farm2: List<String>): List<String> {

    val intersectedFarm = mutableListOf<String>()
    var f1 = 0
    while (f1 < farm1.size) {
        var f2 = 0
        while (f2 < farm2.size) {
            if (farm1[f1] !in intersectedFarm && farm1[f1] == farm2[f2]) {
                intersectedFarm.add(farm1[f1])
            }
            f2++
        }
        f1++
    }
    return intersectedFarm
}