/**
 * This exercise requires you to write a function that takes in two lists as arguments and returns a new list containing the elements that are common in both lists.
 *
 * Complete the function 'findCommonElements' by filling in the missing code using Kotlin's set intersection operation.
 *
 * @param list1 A list containing elements of any type.
 * @param list2 Another list containing elements of any type.
 * @return A new list containing the elements that are common in both lists.
 *
 * Examples:
 * 1. findCommonElements(listOf("a", "b", "c"), listOf("b", "c", "d")) should return listOf("b", "c").
 * 2. findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5)) should return listOf(3, 4).
 * 3. findCommonElements(listOf("apple", "banana", "cherry"), listOf("pear", "banana", "grapefruit")) should return listOf("banana").
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = (list1.toSet() intersect list2.toSet()).toList()
    return commonElements
}
/**
 * This exercise requires you to write a function that takes in two lists as arguments and returns a new list containing the elements that are common in both lists.
 *
 * Complete the function 'findCommonElements' by filling in the missing code using Kotlin's set intersection operation.
 *
 * @param list1 A list containing elements of any type.
 * @param list2 Another list containing elements of any type.
 * @return A new list containing the elements that are common in both lists.
 *
 * Examples:
 * 1. findCommonElements(listOf("a", "b", "c"), listOf("b", "c", "d")) should return listOf("b", "c").
 * 2. findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5)) should return listOf(3, 4).
 * 3. findCommonElements(listOf("apple", "banana", "cherry"), listOf("pear", "banana", "grapefruit")) should return listOf("banana").
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This exercise requires you to write a function that takes in two lists as arguments and returns a new list containing the elements that are common in both lists.
 *
 * Complete the function 'findCommonElements' by filling in the missing code using Kotlin's set intersection operation.
 *
 * @param list1 A list containing elements of any type.
 * @param list2 Another list containing elements of any type.
 * @return A new list containing the elements that are common in both lists.
 *
 * Examples:
 * 1. findCommonElements(listOf("a", "b", "c"), listOf("b", "c", "d")) should return listOf("b", "c").
 * 2. findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5)) should return listOf(3, 4).
 * 3. findCommonElements(listOf("apple", "banana", "cherry"), listOf("pear", "banana", "grapefruit")) should return listOf("banana").
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = (list1.toSet() intersect list2.toSet()).toList()
    return commonElements
}