/**
 * This exercise focuses on the intersection of "What is a tuple?" and "Tuples".
 *
 * Given a list of words and tuples, your task is to find the words that are present in both the word list and any of the tuples.
 *
 * Example:
 *
 * wordList = listOf("apple", "banana", "cherry", "date")
 * tupleList = listOf(Pair("cherry", "grape"), Pair("banana", "kiwi"), Pair("date", "fig"))
 *
 * val intersection = tupleIntersection(wordList, tupleList)
 * println(intersection)
 *
 * Output:
 * ["banana", "cherry", "date"]
 */
fun tupleIntersection(wordList: List<String>, tupleList: List<Pair<String, String>>): List<String> {

    val intersection = mutableListOf<String>()

    // Loop through each word in the word list
    for (word in wordList) {
        // Loop through each tuple in the tuple list
        for (tup in tupleList) {
            // Check if the word is present in the current tuple
            if (word in tup.toList()) {
                // Add the word to the intersection list if it is indeed present in the tuple
                intersection.add(word)
            }
        }
    }

    return intersection
}
/**
 * This exercise focuses on the intersection of "What is a tuple?" and "Tuples".
 *
 * Given a list of words and tuples, your task is to find the words that are present in both the word list and any of the tuples.
 *
 * Example:
 *
 * wordList = listOf("apple", "banana", "cherry", "date")
 * tupleList = listOf(Pair("cherry", "grape"), Pair("banana", "kiwi"), Pair("date", "fig"))
 *
 * val intersection = tupleIntersection(wordList, tupleList)
 * println(intersection)
 *
 * Output:
 * ["banana", "cherry", "date"]
 */
fun tupleIntersection(wordList: List<String>, tupleList: List<Pair<String, String>>): List<String> {
/**
 * This exercise focuses on the intersection of "What is a tuple?" and "Tuples".
 *
 * Given a list of words and tuples, your task is to find the words that are present in both the word list and any of the tuples.
 *
 * Example:
 *
 * wordList = listOf("apple", "banana", "cherry", "date")
 * tupleList = listOf(Pair("cherry", "grape"), Pair("banana", "kiwi"), Pair("date", "fig"))
 *
 * val intersection = tupleIntersection(wordList, tupleList)
 * println(intersection)
 *
 * Output:
 * ["banana", "cherry", "date"]
 */
fun tupleIntersection(wordList: List<String>, tupleList: List<Pair<String, String>>): List<String> {

    val intersection = mutableListOf<String>()

    // Loop through each word in the word list
    for (word in wordList) {
        // Loop through each tuple in the tuple list
        for (tup in tupleList) {
            // Check if the word is present in the current tuple
            if (word in tup.toList()) {
                // Add the word to the intersection list if it is indeed present in the tuple
                intersection.add(word)
            }
        }
    }

    return intersection
}