/**
 * This function takes two strings as input and returns a list of common characters between them.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()

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

    for (char1 in cleanedString1) {
        var flag = false

        for (char2 in cleanedString2) {
            if (char1 == char2) {
                flag = true
                break
            }
        }

        if (flag) {
            commonChars.add(char1)
        }
    }

    return commonChars.sorted()
}

// Exercise: Given two strings, find the common characters using loops and the OR operator.
// Return the result as a list of characters in alphabetical order.

// Example usage:
// findCommonCharacters("abc", "bcd")
/**
 * This function takes two strings as input and returns a list of common characters between them.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {
/**
 * This function takes two strings as input and returns a list of common characters between them.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()

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

    for (char1 in cleanedString1) {
        var flag = false

        for (char2 in cleanedString2) {
            if (char1 == char2) {
                flag = true
                break
            }
        }

        if (flag) {
            commonChars.add(char1)
        }
    }

    return commonChars.sorted()
}

// Exercise: Given two strings, find the common characters using loops and the OR operator.
// Return the result as a list of characters in alphabetical order.

// Example usage:
// findCommonCharacters("abc", "bcd")