/**
 * This function takes in a list of tuples and finds the intersection of the tuples using indexing and slicing.
 * The intersection of tuples is a tuple that contains all the common elements from all the tuples, without repetition.
 * The function returns the intersection tuple.
 *
 * @param tuples A list of tuples.
 * @return The intersection tuple.
 *
 * Example:
 * intersectionOfIndexingAndSlicingTuples(listOf(1, 2, 3), listOf(2, 3, 4), listOf(3, 4, 5))
 * // Returns: listOf(3)
 *
 * intersectionOfIndexingAndSlicingTuples(listOf(1, 2, 3), listOf(4, 5, 6), listOf(2, 3, 4))
 * // Returns: listOf(2, 3)
 */
fun intersectionOfIndexingAndSlicingTuples(tuples: List<List<Int>>): List<Int> {

    var intersection = tuples[0].toSet() // Retrieve the first tuple as the initial set
    for (t in tuples.subList(1, tuples.size)) { // Iterate over the remaining tuples
        intersection = intersection.intersect(t.toSet())
    }
    
    // Sort the intersection tuple to ensure consistent order
    return intersection.sorted()
}
/**
 * This function takes in a list of tuples and finds the intersection of the tuples using indexing and slicing.
 * The intersection of tuples is a tuple that contains all the common elements from all the tuples, without repetition.
 * The function returns the intersection tuple.
 *
 * @param tuples A list of tuples.
 * @return The intersection tuple.
 *
 * Example:
 * intersectionOfIndexingAndSlicingTuples(listOf(1, 2, 3), listOf(2, 3, 4), listOf(3, 4, 5))
 * // Returns: listOf(3)
 *
 * intersectionOfIndexingAndSlicingTuples(listOf(1, 2, 3), listOf(4, 5, 6), listOf(2, 3, 4))
 * // Returns: listOf(2, 3)
 */
fun intersectionOfIndexingAndSlicingTuples(tuples: List<List<Int>>): List<Int> {
/**
 * This function takes in a list of tuples and finds the intersection of the tuples using indexing and slicing.
 * The intersection of tuples is a tuple that contains all the common elements from all the tuples, without repetition.
 * The function returns the intersection tuple.
 *
 * @param tuples A list of tuples.
 * @return The intersection tuple.
 *
 * Example:
 * intersectionOfIndexingAndSlicingTuples(listOf(1, 2, 3), listOf(2, 3, 4), listOf(3, 4, 5))
 * // Returns: listOf(3)
 *
 * intersectionOfIndexingAndSlicingTuples(listOf(1, 2, 3), listOf(4, 5, 6), listOf(2, 3, 4))
 * // Returns: listOf(2, 3)
 */
fun intersectionOfIndexingAndSlicingTuples(tuples: List<List<Int>>): List<Int> {

    var intersection = tuples[0].toSet() // Retrieve the first tuple as the initial set
    for (t in tuples.subList(1, tuples.size)) { // Iterate over the remaining tuples
        intersection = intersection.intersect(t.toSet())
    }
    
    // Sort the intersection tuple to ensure consistent order
    return intersection.sorted()
}