/**
 * Write a function that takes in two strings and returns a list of common characters at the same index in both strings.
 * If the strings have different lengths, consider only the characters up to the length of the shorter string.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters at the same index in both strings.
 *
 * Example:
 * extractCommonCharacters("Mathematician", "mathematics") returns ['m', 'a', 't', 'h', 'e', 'm', 'a', 't', 'i']
 */
fun extractCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()
    val length = minOf(string1.length, string2.length)

    for (i in 0 until length) {
        if (string1[i] == string2[i]) {
            commonChars.add(string1[i])
        }
    }

    return commonChars
}
/**
 * Write a function that takes in two strings and returns a list of common characters at the same index in both strings.
 * If the strings have different lengths, consider only the characters up to the length of the shorter string.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters at the same index in both strings.
 *
 * Example:
 * extractCommonCharacters("Mathematician", "mathematics") returns ['m', 'a', 't', 'h', 'e', 'm', 'a', 't', 'i']
 */
fun extractCommonCharacters(string1: String, string2: String): List<Char> {
/**
 * Write a function that takes in two strings and returns a list of common characters at the same index in both strings.
 * If the strings have different lengths, consider only the characters up to the length of the shorter string.
 *
 * @param string1 The first string.
 * @param string2 The second string.
 * @return A list of common characters at the same index in both strings.
 *
 * Example:
 * extractCommonCharacters("Mathematician", "mathematics") returns ['m', 'a', 't', 'h', 'e', 'm', 'a', 't', 'i']
 */
fun extractCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()
    val length = minOf(string1.length, string2.length)

    for (i in 0 until length) {
        if (string1[i] == string2[i]) {
            commonChars.add(string1[i])
        }
    }

    return commonChars
}