/**
 * Write code to find the common elements between two lists using identity comparison.
 * You are not allowed to use any built-in functions or libraries.
 *
 * list1 = [1, 2, 3, 4, 5]
 * list2 = [2, 4, 6, 8]
 * Expected output: [2, 4]
 */
fun exercise() {

    val list1 = listOf(1, 2, 3, 4, 5)
    val list2 = listOf(2, 4, 6, 8)

    val commonElements = findCommonElements(list1, list2)

    // Verify correct results using identity comparison
    require(commonElements[0] === 2)
    require(commonElements[1] === 4)

    println("Common elements found: $commonElements")
}

fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
    val commonElements = mutableListOf<Int>()
    for (element1 in list1) {
        for (element2 in list2) {
            if (element1 === element2) {
                commonElements.add(element1)
                break
            }
        }
    }
    return commonElements
}
/**
 * Write code to find the common elements between two lists using identity comparison.
 * You are not allowed to use any built-in functions or libraries.
 *
 * list1 = [1, 2, 3, 4, 5]
 * list2 = [2, 4, 6, 8]
 * Expected output: [2, 4]
 */
fun exercise() {
/**
 * Write code to find the common elements between two lists using identity comparison.
 * You are not allowed to use any built-in functions or libraries.
 *
 * list1 = [1, 2, 3, 4, 5]
 * list2 = [2, 4, 6, 8]
 * Expected output: [2, 4]
 */
fun exercise() {

    val list1 = listOf(1, 2, 3, 4, 5)
    val list2 = listOf(2, 4, 6, 8)

    val commonElements = findCommonElements(list1, list2)

    // Verify correct results using identity comparison
    require(commonElements[0] === 2)
    require(commonElements[1] === 4)

    println("Common elements found: $commonElements")
}

fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
    val commonElements = mutableListOf<Int>()
    for (element1 in list1) {
        for (element2 in list2) {
            if (element1 === element2) {
                commonElements.add(element1)
                break
            }
        }
    }
    return commonElements
}