/**
 * This function takes in two sequences and finds the intersection of the two sequences using nested while loops.
 *
 * @param sequence1 First sequence.
 * @param sequence2 Second sequence.
 * @return Intersection of the two sequences.
 */
fun nestedSequenceSequence(sequence1: List<Any>, sequence2: List<Any>): List<Any> {

    val intersection = mutableListOf<Any>()
    var i = 0
    while (i < sequence1.size) {
        var j = 0
        var found = false
        while (j < sequence2.size) {
            if (sequence1[i] == sequence2[j]) {
                intersection.add(sequence1[i])
                found = true
                break
            }
            j++
        }
        if (found) {
            i++
        } else {
            i++
        }
    }
    return intersection
}
/**
 * This function takes in two sequences and finds the intersection of the two sequences using nested while loops.
 *
 * @param sequence1 First sequence.
 * @param sequence2 Second sequence.
 * @return Intersection of the two sequences.
 */
fun nestedSequenceSequence(sequence1: List<Any>, sequence2: List<Any>): List<Any> {
/**
 * This function takes in two sequences and finds the intersection of the two sequences using nested while loops.
 *
 * @param sequence1 First sequence.
 * @param sequence2 Second sequence.
 * @return Intersection of the two sequences.
 */
fun nestedSequenceSequence(sequence1: List<Any>, sequence2: List<Any>): List<Any> {

    val intersection = mutableListOf<Any>()
    var i = 0
    while (i < sequence1.size) {
        var j = 0
        var found = false
        while (j < sequence2.size) {
            if (sequence1[i] == sequence2[j]) {
                intersection.add(sequence1[i])
                found = true
                break
            }
            j++
        }
        if (found) {
            i++
        } else {
            i++
        }
    }
    return intersection
}