/**
 * Given two lists, this function finds the common elements between them.
 *
 * @param list1 a list of elements
 * @param list2 another list of elements
 * @return a list of common elements found in both list1 and list2
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("grape", "apple", "orange")) // ["apple", "orange"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val common = mutableListOf<Any>()

    for (element in list1) {
        if (element in list2 && element !in common) {
            common.add(element)
        }
    }

    return common
}

val list1 = listOf(1, 2, 3, 4, 4)
/**
 * Given two lists, this function finds the common elements between them.
 *
 * @param list1 a list of elements
 * @param list2 another list of elements
 * @return a list of common elements found in both list1 and list2
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("grape", "apple", "orange")) // ["apple", "orange"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, this function finds the common elements between them.
 *
 * @param list1 a list of elements
 * @param list2 another list of elements
 * @return a list of common elements found in both list1 and list2
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("grape", "apple", "orange")) // ["apple", "orange"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val common = mutableListOf<Any>()

    for (element in list1) {
        if (element in list2 && element !in common) {
            common.add(element)
        }
    }

    return common
}

val list1 = listOf(1, 2, 3, 4, 4)