/**
 * Given two strings, find and return a string containing the common characters found inside both strings.
 *
 * @param string1 The first input string.
 * @param string2 The second input string.
 * @return A string containing the common characters found inside both strings.
 *
 * Example:
 * findCommonChars("astronomy", "observatory") -> "atory"
 */
fun findCommonChars(string1: String, string2: String): String {

    var commonChars = ""

    // Remove any whitespace characters from the strings
    val cleanedString1 = string1.replace(" ", "")
    val cleanedString2 = string2.replace(" ", "")

    // Loop through the characters in string1
    for (char1 in cleanedString1) {
        // Loop through the characters in string2
        for (char2 in cleanedString2) {
            // Check if the current character in string1 is equal to the current character in string2
            if (char1 == char2) {
                // Check if the common character is already present in the commonChars string
                if (!commonChars.contains(char1)) {
                    // Add the common character to the commonChars string
                    commonChars += char1
                }
            }
        }
    }

    return commonChars
}
/**
 * Given two strings, find and return a string containing the common characters found inside both strings.
 *
 * @param string1 The first input string.
 * @param string2 The second input string.
 * @return A string containing the common characters found inside both strings.
 *
 * Example:
 * findCommonChars("astronomy", "observatory") -> "atory"
 */
fun findCommonChars(string1: String, string2: String): String {
/**
 * Given two strings, find and return a string containing the common characters found inside both strings.
 *
 * @param string1 The first input string.
 * @param string2 The second input string.
 * @return A string containing the common characters found inside both strings.
 *
 * Example:
 * findCommonChars("astronomy", "observatory") -> "atory"
 */
fun findCommonChars(string1: String, string2: String): String {

    var commonChars = ""

    // Remove any whitespace characters from the strings
    val cleanedString1 = string1.replace(" ", "")
    val cleanedString2 = string2.replace(" ", "")

    // Loop through the characters in string1
    for (char1 in cleanedString1) {
        // Loop through the characters in string2
        for (char2 in cleanedString2) {
            // Check if the current character in string1 is equal to the current character in string2
            if (char1 == char2) {
                // Check if the common character is already present in the commonChars string
                if (!commonChars.contains(char1)) {
                    // Add the common character to the commonChars string
                    commonChars += char1
                }
            }
        }
    }

    return commonChars
}