/**
 * You are a civil engineer working on a project that involves checking for the intersection of two lists.
 * Complete the function below to find the elements present in both lists using identity comparison.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the elements that are present in both list1 and list2 using identity comparison.
 *
 * Example:
 * '``
 * val list1 = listOf(1, 2, 3, 4, 5)
 * val list2 = listOf(2, 4, 6, 8)
 * println(identityListIntersection(list1, list2)) // Output: [2, 4]
 * '``
 */
fun identityListIntersection(list1: List<Any>, list2: List<Any>): List<Any> {

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

    // Iterate through the elements of list1
    for (element in list1) {
        // Check if the element is present in list2 using identity comparison
        if (list2.contains(element)) {
            // Append the common element to the commonElements list
            commonElements.add(element)
        }
    }

    // Return the commonElements list
    return commonElements
}
/**
 * You are a civil engineer working on a project that involves checking for the intersection of two lists.
 * Complete the function below to find the elements present in both lists using identity comparison.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the elements that are present in both list1 and list2 using identity comparison.
 *
 * Example:
 * '``
 * val list1 = listOf(1, 2, 3, 4, 5)
 * val list2 = listOf(2, 4, 6, 8)
 * println(identityListIntersection(list1, list2)) // Output: [2, 4]
 * '``
 */
fun identityListIntersection(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * You are a civil engineer working on a project that involves checking for the intersection of two lists.
 * Complete the function below to find the elements present in both lists using identity comparison.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing the elements that are present in both list1 and list2 using identity comparison.
 *
 * Example:
 * '``
 * val list1 = listOf(1, 2, 3, 4, 5)
 * val list2 = listOf(2, 4, 6, 8)
 * println(identityListIntersection(list1, list2)) // Output: [2, 4]
 * '``
 */
fun identityListIntersection(list1: List<Any>, list2: List<Any>): List<Any> {

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

    // Iterate through the elements of list1
    for (element in list1) {
        // Check if the element is present in list2 using identity comparison
        if (list2.contains(element)) {
            // Append the common element to the commonElements list
            commonElements.add(element)
        }
    }

    // Return the commonElements list
    return commonElements
}