/**
 * Given two lists, returns a new list containing the common elements
 * between the two lists.
 *
 * @param list1 The first list of elements.
 * @param list2 The second list of elements.
 * @return A new list containing only the common elements between the two lists.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "orange", "grape"), listOf("orange", "kiwi", "grape")) // ["orange", "grape"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    for (elem in list1) {
        if (elem in list2) {
            commonElements.add(elem)
        }
    }

    return commonElements
}
/**
 * Given two lists, returns a new list containing the common elements
 * between the two lists.
 *
 * @param list1 The first list of elements.
 * @param list2 The second list of elements.
 * @return A new list containing only the common elements between the two lists.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "orange", "grape"), listOf("orange", "kiwi", "grape")) // ["orange", "grape"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, returns a new list containing the common elements
 * between the two lists.
 *
 * @param list1 The first list of elements.
 * @param list2 The second list of elements.
 * @return A new list containing only the common elements between the two lists.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "orange", "grape"), listOf("orange", "kiwi", "grape")) // ["orange", "grape"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    for (elem in list1) {
        if (elem in list2) {
            commonElements.add(elem)
        }
    }

    return commonElements
}