/**
 * This exercise requires you to find the intersection of two tuples using slicing and indexing.
 * Given two tuples, your task is to write a function that returns a new tuple containing only the elements that are present in both input tuples.
 *
 * @param tup1 The first input tuple
 * @param tup2 The second input tuple
 * @return The new tuple containing the intersection elements
 *
 * Note:
 * - The elements in the returned tuple should maintain the relative order as they appear in the first tuple.
 * - The function should handle duplicate elements in the input tuples correctly.
 * - If there are no common elements between the two tuples, the function should return an empty tuple.
 */
fun intersectTuples(tup1: List<Any>, tup2: List<Any>): List<Any> {

    // Initialize an empty list to store the common elements
    val commonElements = mutableListOf<Any>()
    
    // Iterate over the first tuple
    for (element in tup1) {
        // Check if the element is present in both tuples
        if (element in tup2) {
            // Append the element to the commonElements list
            commonElements.add(element)
        }
    }
    
    // Return the commonElements list
    return commonElements
}
/**
 * This exercise requires you to find the intersection of two tuples using slicing and indexing.
 * Given two tuples, your task is to write a function that returns a new tuple containing only the elements that are present in both input tuples.
 *
 * @param tup1 The first input tuple
 * @param tup2 The second input tuple
 * @return The new tuple containing the intersection elements
 *
 * Note:
 * - The elements in the returned tuple should maintain the relative order as they appear in the first tuple.
 * - The function should handle duplicate elements in the input tuples correctly.
 * - If there are no common elements between the two tuples, the function should return an empty tuple.
 */
fun intersectTuples(tup1: List<Any>, tup2: List<Any>): List<Any> {
/**
 * This exercise requires you to find the intersection of two tuples using slicing and indexing.
 * Given two tuples, your task is to write a function that returns a new tuple containing only the elements that are present in both input tuples.
 *
 * @param tup1 The first input tuple
 * @param tup2 The second input tuple
 * @return The new tuple containing the intersection elements
 *
 * Note:
 * - The elements in the returned tuple should maintain the relative order as they appear in the first tuple.
 * - The function should handle duplicate elements in the input tuples correctly.
 * - If there are no common elements between the two tuples, the function should return an empty tuple.
 */
fun intersectTuples(tup1: List<Any>, tup2: List<Any>): List<Any> {

    // Initialize an empty list to store the common elements
    val commonElements = mutableListOf<Any>()
    
    // Iterate over the first tuple
    for (element in tup1) {
        // Check if the element is present in both tuples
        if (element in tup2) {
            // Append the element to the commonElements list
            commonElements.add(element)
        }
    }
    
    // Return the commonElements list
    return commonElements
}