/**
 * Given two words as input, this function finds the common letters between them
 * and returns them as a list in alphabetical order.
 */
fun findCommonLetters(word1: String, word2: String): List<Char> {

    val commonLetters = mutableListOf<Char>()
    var index1 = 0
    while (index1 < word1.length) {
        var index2 = 0
        while (index2 < word2.length) {
            if (word1[index1] == word2[index2] && word1[index1] !in commonLetters) {
                commonLetters.add(word1[index1])
            }
            index2++
        }
        index1++
    }
    return commonLetters.sorted()
}
/**
 * Given two words as input, this function finds the common letters between them
 * and returns them as a list in alphabetical order.
 */
fun findCommonLetters(word1: String, word2: String): List<Char> {
/**
 * Given two words as input, this function finds the common letters between them
 * and returns them as a list in alphabetical order.
 */
fun findCommonLetters(word1: String, word2: String): List<Char> {

    val commonLetters = mutableListOf<Char>()
    var index1 = 0
    while (index1 < word1.length) {
        var index2 = 0
        while (index2 < word2.length) {
            if (word1[index1] == word2[index2] && word1[index1] !in commonLetters) {
                commonLetters.add(word1[index1])
            }
            index2++
        }
        index1++
    }
    return commonLetters.sorted()
}