/**
 * This function takes a list of articles as input and returns a set of common words
 * that appear in all the articles.
 *
 * @param articles A list of articles.
 * @return Set of common words.
 *
 * Example:
 * val articles = listOf(
 *     "New research shows that climate change is a pressing issue",
 *     "The government plans to implement new policies to address climate change",
 *     "Climate change has significant impact on global warming"
 * )
 * findCommonWords(articles) // Output: setOf("climate", "change")
 */
fun findCommonWords(articles: List<String>): Set<String> {

    // Create a set of all words in the first article
    var commonWords = articles[0].toLowerCase().split(" ").toSet()

    // Iterate through each article starting from the second one
    for (article in articles.subList(1, articles.size)) {
        // Create a set of words in the current article
        val articleWords = article.toLowerCase().split(" ").toSet()

        // Take the intersection of the commonWords set and articleWords set
        // to find the common words between the two sets
        commonWords = commonWords.intersect(articleWords)
    }

    return commonWords
}
/**
 * This function takes a list of articles as input and returns a set of common words
 * that appear in all the articles.
 *
 * @param articles A list of articles.
 * @return Set of common words.
 *
 * Example:
 * val articles = listOf(
 *     "New research shows that climate change is a pressing issue",
 *     "The government plans to implement new policies to address climate change",
 *     "Climate change has significant impact on global warming"
 * )
 * findCommonWords(articles) // Output: setOf("climate", "change")
 */
fun findCommonWords(articles: List<String>): Set<String> {
/**
 * This function takes a list of articles as input and returns a set of common words
 * that appear in all the articles.
 *
 * @param articles A list of articles.
 * @return Set of common words.
 *
 * Example:
 * val articles = listOf(
 *     "New research shows that climate change is a pressing issue",
 *     "The government plans to implement new policies to address climate change",
 *     "Climate change has significant impact on global warming"
 * )
 * findCommonWords(articles) // Output: setOf("climate", "change")
 */
fun findCommonWords(articles: List<String>): Set<String> {

    // Create a set of all words in the first article
    var commonWords = articles[0].toLowerCase().split(" ").toSet()

    // Iterate through each article starting from the second one
    for (article in articles.subList(1, articles.size)) {
        // Create a set of words in the current article
        val articleWords = article.toLowerCase().split(" ").toSet()

        // Take the intersection of the commonWords set and articleWords set
        // to find the common words between the two sets
        commonWords = commonWords.intersect(articleWords)
    }

    return commonWords
}