/**
 * Write a function that takes a list of tuples and an index value as input.
 * The function should find the intersection of all the tuples and delete the element at the given index in each tuple.
 *
 * Example:
 * tuples = [(1, 2, 3), (2, 3, 4), (3, 4, 5)]
 * idx = 1
 *
 * After finding the intersection and deleting the element at index 1, the expected result is:
 * [(1, 3), (2,), (3,)]
 */
fun intersectionAndDeletion(tuples: List<List<Int>>, idx: Int): List<List<Int>> {

    // Find intersection of all tuples
    var intersection = tuples[0].toSet()
    for (t in tuples.drop(1)) {
        intersection = intersection.intersect(t.toSet())
    }

    // Delete element at index idx in each tuple
    val result = tuples.map { tuple ->
        tuple.filterIndexed { index, _ -> index != idx }
    }

    return result
}
/**
 * Write a function that takes a list of tuples and an index value as input.
 * The function should find the intersection of all the tuples and delete the element at the given index in each tuple.
 *
 * Example:
 * tuples = [(1, 2, 3), (2, 3, 4), (3, 4, 5)]
 * idx = 1
 *
 * After finding the intersection and deleting the element at index 1, the expected result is:
 * [(1, 3), (2,), (3,)]
 */
fun intersectionAndDeletion(tuples: List<List<Int>>, idx: Int): List<List<Int>> {
/**
 * Write a function that takes a list of tuples and an index value as input.
 * The function should find the intersection of all the tuples and delete the element at the given index in each tuple.
 *
 * Example:
 * tuples = [(1, 2, 3), (2, 3, 4), (3, 4, 5)]
 * idx = 1
 *
 * After finding the intersection and deleting the element at index 1, the expected result is:
 * [(1, 3), (2,), (3,)]
 */
fun intersectionAndDeletion(tuples: List<List<Int>>, idx: Int): List<List<Int>> {

    // Find intersection of all tuples
    var intersection = tuples[0].toSet()
    for (t in tuples.drop(1)) {
        intersection = intersection.intersect(t.toSet())
    }

    // Delete element at index idx in each tuple
    val result = tuples.map { tuple ->
        tuple.filterIndexed { index, _ -> index != idx }
    }

    return result
}