/**
 * This exercise asks you to find the common elements between two lists.
 * You are required to use looping statements and the '===' operator.
 */
fun commonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    // Initialize an empty list to store the common elements
    val common = mutableListOf<Any>()

    // Loop through each element in list1
    for (elem1 in list1) {
        // Variable to check if the element is common
        var isCommon = false

        // Loop through each element in list2
        for (elem2 in list2) {
            // If the elements are the same and have the same identity
            if (elem1 === elem2) {
                // Set the flag to true
                isCommon = true

                // Optimize by breaking this internal loop as we already found a match
                break
            }
        }

        // If the element is common, add it to the common list
        if (isCommon) {
            common.add(elem1)
        }
    }

    return common
}
/**
 * This exercise asks you to find the common elements between two lists.
 * You are required to use looping statements and the '===' operator.
 */
fun commonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This exercise asks you to find the common elements between two lists.
 * You are required to use looping statements and the '===' operator.
 */
fun commonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    // Initialize an empty list to store the common elements
    val common = mutableListOf<Any>()

    // Loop through each element in list1
    for (elem1 in list1) {
        // Variable to check if the element is common
        var isCommon = false

        // Loop through each element in list2
        for (elem2 in list2) {
            // If the elements are the same and have the same identity
            if (elem1 === elem2) {
                // Set the flag to true
                isCommon = true

                // Optimize by breaking this internal loop as we already found a match
                break
            }
        }

        // If the element is common, add it to the common list
        if (isCommon) {
            common.add(elem1)
        }
    }

    return common
}