/**
 * This exercise requires creating a tuple using the tuple() function and using list slicing to find the intersection of two lists.
 *
 * @param list1 a list of elements
 * @param list2 a list of elements
 * @return A tuple containing the elements that are present in both input lists.
 *
 * Example:
 * tupleIntersectionListSlicing(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // Output: (4, 5)
 */
fun tupleIntersectionListSlicing(list1: List<Int>, list2: List<Int>): Pair<Int, Int> {

    // Convert lists to sets to find the intersection
    val set1 = list1.toSet()
    val set2 = list2.toSet()

    // Find the intersecting elements using set intersection
    val intersectingElements = set1.intersect(set2)

    // Convert the set back to a tuple
    return intersectingElements.toList().let { (first, second) -> Pair(first, second) }
}
/**
 * This exercise requires creating a tuple using the tuple() function and using list slicing to find the intersection of two lists.
 *
 * @param list1 a list of elements
 * @param list2 a list of elements
 * @return A tuple containing the elements that are present in both input lists.
 *
 * Example:
 * tupleIntersectionListSlicing(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // Output: (4, 5)
 */
fun tupleIntersectionListSlicing(list1: List<Int>, list2: List<Int>): Pair<Int, Int> {
/**
 * This exercise requires creating a tuple using the tuple() function and using list slicing to find the intersection of two lists.
 *
 * @param list1 a list of elements
 * @param list2 a list of elements
 * @return A tuple containing the elements that are present in both input lists.
 *
 * Example:
 * tupleIntersectionListSlicing(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // Output: (4, 5)
 */
fun tupleIntersectionListSlicing(list1: List<Int>, list2: List<Int>): Pair<Int, Int> {

    // Convert lists to sets to find the intersection
    val set1 = list1.toSet()
    val set2 = list2.toSet()

    // Find the intersecting elements using set intersection
    val intersectingElements = set1.intersect(set2)

    // Convert the set back to a tuple
    return intersectingElements.toList().let { (first, second) -> Pair(first, second) }
}