/**
 * This exercise aims to find the common words between two sentences using boolean functions and string concatenation.
 *
 * The task is to write a function that takes two sentences as input and returns a list of words that are present in both sentences.
 *
 * For example:
 * - Input: "I like to run." and "She likes to run, too."
 * - Output: ['to', 'run']
 *
 * You need to complete the function 'findCommonWords' below to solve this exercise.
 */
fun findCommonWords(sentence1: String, sentence2: String): List<String> {

    // Split the sentences into lists of words
    val words1 = sentence1.split(" ")
    val words2 = sentence2.split(" ")

    // Initialize an empty list to store common words
    val commonWords = mutableListOf<String>()

    // Iterate over each word in the first sentence
    for (word1 in words1) {
        // Iterate over each word in the second sentence
        for (word2 in words2) {
            // Check if the current word in the first sentence is equal to the current word in the second sentence
            if (word1 == word2) {
                // Append the common word to the list
                commonWords.add(word1)
                // Break the inner loop to avoid duplicate entries
                break
            }
        }
    }

    // Return the list of common words
    return commonWords
}
/**
 * This exercise aims to find the common words between two sentences using boolean functions and string concatenation.
 *
 * The task is to write a function that takes two sentences as input and returns a list of words that are present in both sentences.
 *
 * For example:
 * - Input: "I like to run." and "She likes to run, too."
 * - Output: ['to', 'run']
 *
 * You need to complete the function 'findCommonWords' below to solve this exercise.
 */
fun findCommonWords(sentence1: String, sentence2: String): List<String> {
/**
 * This exercise aims to find the common words between two sentences using boolean functions and string concatenation.
 *
 * The task is to write a function that takes two sentences as input and returns a list of words that are present in both sentences.
 *
 * For example:
 * - Input: "I like to run." and "She likes to run, too."
 * - Output: ['to', 'run']
 *
 * You need to complete the function 'findCommonWords' below to solve this exercise.
 */
fun findCommonWords(sentence1: String, sentence2: String): List<String> {

    // Split the sentences into lists of words
    val words1 = sentence1.split(" ")
    val words2 = sentence2.split(" ")

    // Initialize an empty list to store common words
    val commonWords = mutableListOf<String>()

    // Iterate over each word in the first sentence
    for (word1 in words1) {
        // Iterate over each word in the second sentence
        for (word2 in words2) {
            // Check if the current word in the first sentence is equal to the current word in the second sentence
            if (word1 == word2) {
                // Append the common word to the list
                commonWords.add(word1)
                // Break the inner loop to avoid duplicate entries
                break
            }
        }
    }

    // Return the list of common words
    return commonWords
}