/**
 * This exercise tests your ability to create a tuple from a string and loop through tuples. You are given a string
 * and a list of tuples. Your task is to create a new list that contains all the tuples from the original list that
 * have at least one element in common with the string. The elements in the string and tuples can be of any type.
 *
 * @param string The input string.
 * @param tupleList The list of tuples.
 * @return A new list containing tuples that have at least one element in common with the string.
 */
fun tupleIntersection(string: String, tupleList: List<List<Any>>): List<List<Any>> {

    // Create an empty list to store the matching tuples
    val matchingTuples = mutableListOf<List<Any>>()

    // Convert the string into a set of characters
    val stringSet = string.toSet()

    // Loop through each tuple in the list
    for (t in tupleList) {
        // Convert the tuple into a set of elements
        val tupleSet = t.toSet()

        // Check if there is any intersection between the string set and the tuple set
        if (stringSet.intersect(tupleSet).isNotEmpty()) {
            matchingTuples.add(t)
        }
    }

    // Return the list of matching tuples
    return matchingTuples
}
/**
 * This exercise tests your ability to create a tuple from a string and loop through tuples. You are given a string
 * and a list of tuples. Your task is to create a new list that contains all the tuples from the original list that
 * have at least one element in common with the string. The elements in the string and tuples can be of any type.
 *
 * @param string The input string.
 * @param tupleList The list of tuples.
 * @return A new list containing tuples that have at least one element in common with the string.
 */
fun tupleIntersection(string: String, tupleList: List<List<Any>>): List<List<Any>> {
/**
 * This exercise tests your ability to create a tuple from a string and loop through tuples. You are given a string
 * and a list of tuples. Your task is to create a new list that contains all the tuples from the original list that
 * have at least one element in common with the string. The elements in the string and tuples can be of any type.
 *
 * @param string The input string.
 * @param tupleList The list of tuples.
 * @return A new list containing tuples that have at least one element in common with the string.
 */
fun tupleIntersection(string: String, tupleList: List<List<Any>>): List<List<Any>> {

    // Create an empty list to store the matching tuples
    val matchingTuples = mutableListOf<List<Any>>()

    // Convert the string into a set of characters
    val stringSet = string.toSet()

    // Loop through each tuple in the list
    for (t in tupleList) {
        // Convert the tuple into a set of elements
        val tupleSet = t.toSet()

        // Check if there is any intersection between the string set and the tuple set
        if (stringSet.intersect(tupleSet).isNotEmpty()) {
            matchingTuples.add(t)
        }
    }

    // Return the list of matching tuples
    return matchingTuples
}