/**
 * An archaeologist has discovered two ancient lists of artifacts and wants to find the common elements present in both lists.
 * Complete the function 'findCommonElements' which takes in two lists as arguments and returns a new list containing the common elements.
 *
 * Hint: The common elements between the two lists should not repeat in the final list and their order should be the same as the first list.
 *
 * @param list1 The first list of artifacts.
 * @param list2 The second list of artifacts.
 * @return A new list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()  // Empty list to store common elements

    // Iterate over each element in the first list
    for (element in list1) {
        // Check if the element is present in both lists and not already in the commonElements list
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)  // Add the element to the commonElements list
        }
    }

    return commonElements
}
/**
 * An archaeologist has discovered two ancient lists of artifacts and wants to find the common elements present in both lists.
 * Complete the function 'findCommonElements' which takes in two lists as arguments and returns a new list containing the common elements.
 *
 * Hint: The common elements between the two lists should not repeat in the final list and their order should be the same as the first list.
 *
 * @param list1 The first list of artifacts.
 * @param list2 The second list of artifacts.
 * @return A new list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * An archaeologist has discovered two ancient lists of artifacts and wants to find the common elements present in both lists.
 * Complete the function 'findCommonElements' which takes in two lists as arguments and returns a new list containing the common elements.
 *
 * Hint: The common elements between the two lists should not repeat in the final list and their order should be the same as the first list.
 *
 * @param list1 The first list of artifacts.
 * @param list2 The second list of artifacts.
 * @return A new list containing the common elements between list1 and list2.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()  // Empty list to store common elements

    // Iterate over each element in the first list
    for (element in list1) {
        // Check if the element is present in both lists and not already in the commonElements list
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)  // Add the element to the commonElements list
        }
    }

    return commonElements
}