/**
 * This exercise requires you to find the common elements between two sequences using iteration and the OR operator.
 *
 * Complete the function intersection(), which takes in two sequences and returns a list of their common elements.
 *
 * For example,
 * intersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) should return [4, 5].
 * intersection(listOf('a', 'b', 'c'), listOf('c', 'd', 'e')) should return ['c'].
 *
 * Your task is to implement the intersection function by using the OR operator in a loop to check each element of sequence1
 * and sequence2 for their intersection.
 *
 * You should not use any built-in functions or libraries that can directly find the intersection for you.
 *
 * You may need to use conditional statements, a loop, and the OR operator (|) to solve this exercise.
 */
fun intersection(sequence1: List<Any>, sequence2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    for (element1 in sequence1) {
        for (element2 in sequence2) {
            if (element1 == element2) {
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}
/**
 * This exercise requires you to find the common elements between two sequences using iteration and the OR operator.
 *
 * Complete the function intersection(), which takes in two sequences and returns a list of their common elements.
 *
 * For example,
 * intersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) should return [4, 5].
 * intersection(listOf('a', 'b', 'c'), listOf('c', 'd', 'e')) should return ['c'].
 *
 * Your task is to implement the intersection function by using the OR operator in a loop to check each element of sequence1
 * and sequence2 for their intersection.
 *
 * You should not use any built-in functions or libraries that can directly find the intersection for you.
 *
 * You may need to use conditional statements, a loop, and the OR operator (|) to solve this exercise.
 */
fun intersection(sequence1: List<Any>, sequence2: List<Any>): List<Any> {
/**
 * This exercise requires you to find the common elements between two sequences using iteration and the OR operator.
 *
 * Complete the function intersection(), which takes in two sequences and returns a list of their common elements.
 *
 * For example,
 * intersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) should return [4, 5].
 * intersection(listOf('a', 'b', 'c'), listOf('c', 'd', 'e')) should return ['c'].
 *
 * Your task is to implement the intersection function by using the OR operator in a loop to check each element of sequence1
 * and sequence2 for their intersection.
 *
 * You should not use any built-in functions or libraries that can directly find the intersection for you.
 *
 * You may need to use conditional statements, a loop, and the OR operator (|) to solve this exercise.
 */
fun intersection(sequence1: List<Any>, sequence2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    for (element1 in sequence1) {
        for (element2 in sequence2) {
            if (element1 == element2) {
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}