/**
 * This function takes in two strings and returns a set of common words found in both strings.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A set of common words found in both strings.
 * @throws IllegalArgumentException If either string1 or string2 is empty.
 */
fun getCommonWords(string1: String, string2: String): Set<String> {

    if (string1.isEmpty() || string2.isEmpty()) {
        throw IllegalArgumentException("Both strings must not be empty")
    }

    val words1 = string1.split(" ")
    val words2 = string2.split(" ")
    val commonWords = mutableSetOf<String>()

    for (word1 in words1) {
        for (word2 in words2) {
            if (word1 == word2) {
                commonWords.add(word1)
            }
        }
    }

    return commonWords
}
/**
 * This function takes in two strings and returns a set of common words found in both strings.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A set of common words found in both strings.
 * @throws IllegalArgumentException If either string1 or string2 is empty.
 */
fun getCommonWords(string1: String, string2: String): Set<String> {
/**
 * This function takes in two strings and returns a set of common words found in both strings.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A set of common words found in both strings.
 * @throws IllegalArgumentException If either string1 or string2 is empty.
 */
fun getCommonWords(string1: String, string2: String): Set<String> {

    if (string1.isEmpty() || string2.isEmpty()) {
        throw IllegalArgumentException("Both strings must not be empty")
    }

    val words1 = string1.split(" ")
    val words2 = string2.split(" ")
    val commonWords = mutableSetOf<String>()

    for (word1 in words1) {
        for (word2 in words2) {
            if (word1 == word2) {
                commonWords.add(word1)
            }
        }
    }

    return commonWords
}