/**
 * This exercise focuses on identity comparison and iterating over each character of a string.
 * The task is to compare the characters of two strings and return a list of characters that are present in both strings.
 * Identity comparison is used to compare the string characters to ensure accuracy.
 *
 * @param string1 The first string to compare.
 * @param string2 The second string to compare.
 * @return A list of characters that are present in both strings.
 */
fun compareStringCharacters(string1: String, string2: String): List<Char> {

    // Create an empty list to store common characters
    val commonChars = mutableListOf<Char>()

    // Iterate over each character in the first string
    for (char1 in string1) {
        // Use identity comparison to check if the character is present in the second string
        for (char2 in string2) {
            if (char1 == char2) { // Identity comparison using '=='
                // Check if the common character is already in the list
                if (char1 !in commonChars) {
                    commonChars.add(char1)
                }
            }
        }
    }

    return commonChars
}
/**
 * This exercise focuses on identity comparison and iterating over each character of a string.
 * The task is to compare the characters of two strings and return a list of characters that are present in both strings.
 * Identity comparison is used to compare the string characters to ensure accuracy.
 *
 * @param string1 The first string to compare.
 * @param string2 The second string to compare.
 * @return A list of characters that are present in both strings.
 */
fun compareStringCharacters(string1: String, string2: String): List<Char> {
/**
 * This exercise focuses on identity comparison and iterating over each character of a string.
 * The task is to compare the characters of two strings and return a list of characters that are present in both strings.
 * Identity comparison is used to compare the string characters to ensure accuracy.
 *
 * @param string1 The first string to compare.
 * @param string2 The second string to compare.
 * @return A list of characters that are present in both strings.
 */
fun compareStringCharacters(string1: String, string2: String): List<Char> {

    // Create an empty list to store common characters
    val commonChars = mutableListOf<Char>()

    // Iterate over each character in the first string
    for (char1 in string1) {
        // Use identity comparison to check if the character is present in the second string
        for (char2 in string2) {
            if (char1 == char2) { // Identity comparison using '=='
                // Check if the common character is already in the list
                if (char1 !in commonChars) {
                    commonChars.add(char1)
                }
            }
        }
    }

    return commonChars
}