/**
 * This exercise requires you to write a function that takes in two strings and counts the number of common characters between them.
 * The function will use a while loop to iterate through each character in the strings and check if it exists in the other string.
 * Finally, it will return the count of common characters.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return The count of common characters between the two strings.
 */
fun countCommonCharacters(string1: String, string2: String): Int {

    var commonCount = 0
    var index = 0

    while (index < string1.length) {
        val character = string1[index]
        if (string2.contains(character)) {
            commonCount++
            string2.replaceFirst(character.toString(), "")
        }
        index++
    }

    return commonCount
}
/**
 * This exercise requires you to write a function that takes in two strings and counts the number of common characters between them.
 * The function will use a while loop to iterate through each character in the strings and check if it exists in the other string.
 * Finally, it will return the count of common characters.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return The count of common characters between the two strings.
 */
fun countCommonCharacters(string1: String, string2: String): Int {
/**
 * This exercise requires you to write a function that takes in two strings and counts the number of common characters between them.
 * The function will use a while loop to iterate through each character in the strings and check if it exists in the other string.
 * Finally, it will return the count of common characters.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return The count of common characters between the two strings.
 */
fun countCommonCharacters(string1: String, string2: String): Int {

    var commonCount = 0
    var index = 0

    while (index < string1.length) {
        val character = string1[index]
        if (string2.contains(character)) {
            commonCount++
            string2.replaceFirst(character.toString(), "")
        }
        index++
    }

    return commonCount
}