/**
 * This exercise requires the social worker to find the intersection of two tuples using nested while loops.
 * The function takes two tuples as input and returns a new tuple containing their intersection.
 *
 * @param tup1 A tuple containing elements to compare.
 * @param tup2 Another tuple containing elements to compare.
 * @return A new tuple containing the common elements between tup1 and tup2.
 *
 * Example:
 * val tup1 = listOf(1, 2, 3, 4, 5)
 * val tup2 = listOf(4, 5, 6, 7, 8)
 * findIntersection(tup1, tup2) -> listOf(4, 5)
 */
fun findIntersection(tup1: List<Int>, tup2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    var i = 0

    while (i < tup1.size) {
        var j = 0
        while (j < tup2.size) {
            if (tup1[i] == tup2[j]) {
                intersection.add(tup1[i])
            }
            j++
        }
        i++
    }

    return intersection
}
/**
 * This exercise requires the social worker to find the intersection of two tuples using nested while loops.
 * The function takes two tuples as input and returns a new tuple containing their intersection.
 *
 * @param tup1 A tuple containing elements to compare.
 * @param tup2 Another tuple containing elements to compare.
 * @return A new tuple containing the common elements between tup1 and tup2.
 *
 * Example:
 * val tup1 = listOf(1, 2, 3, 4, 5)
 * val tup2 = listOf(4, 5, 6, 7, 8)
 * findIntersection(tup1, tup2) -> listOf(4, 5)
 */
fun findIntersection(tup1: List<Int>, tup2: List<Int>): List<Int> {
/**
 * This exercise requires the social worker to find the intersection of two tuples using nested while loops.
 * The function takes two tuples as input and returns a new tuple containing their intersection.
 *
 * @param tup1 A tuple containing elements to compare.
 * @param tup2 Another tuple containing elements to compare.
 * @return A new tuple containing the common elements between tup1 and tup2.
 *
 * Example:
 * val tup1 = listOf(1, 2, 3, 4, 5)
 * val tup2 = listOf(4, 5, 6, 7, 8)
 * findIntersection(tup1, tup2) -> listOf(4, 5)
 */
fun findIntersection(tup1: List<Int>, tup2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    var i = 0

    while (i < tup1.size) {
        var j = 0
        while (j < tup2.size) {
            if (tup1[i] == tup2[j]) {
                intersection.add(tup1[i])
            }
            j++
        }
        i++
    }

    return intersection
}