/**
 * This exercise requires finding the common letters between two words, using string slicing and membership operations.
 * The function takes two words as arguments and returns a list of common letters.
 *
 * Example:
 * findCommonLetters("chef", "chocolate")
 * Output: ['c', 'h', 'e']
 *
 * findCommonLetters("recipe", "restaurant")
 * Output: ['r', 'e']
 */
fun findCommonLetters(word1: String, word2: String): List<Char> {

    // Initialize an empty list to store the common letters
    val commonLetters = mutableListOf<Char>()

    // Iterate over each character in the first word
    for (letter in word1) {
        // Check if the letter is present in both words
        if (letter in word2) {
            // Add the letter to the commonLetters list if it is not already present
            if (letter !in commonLetters) {
                commonLetters.add(letter)
            }
        }
    }

    // Return the list of common letters
    return commonLetters
}
/**
 * This exercise requires finding the common letters between two words, using string slicing and membership operations.
 * The function takes two words as arguments and returns a list of common letters.
 *
 * Example:
 * findCommonLetters("chef", "chocolate")
 * Output: ['c', 'h', 'e']
 *
 * findCommonLetters("recipe", "restaurant")
 * Output: ['r', 'e']
 */
fun findCommonLetters(word1: String, word2: String): List<Char> {
/**
 * This exercise requires finding the common letters between two words, using string slicing and membership operations.
 * The function takes two words as arguments and returns a list of common letters.
 *
 * Example:
 * findCommonLetters("chef", "chocolate")
 * Output: ['c', 'h', 'e']
 *
 * findCommonLetters("recipe", "restaurant")
 * Output: ['r', 'e']
 */
fun findCommonLetters(word1: String, word2: String): List<Char> {

    // Initialize an empty list to store the common letters
    val commonLetters = mutableListOf<Char>()

    // Iterate over each character in the first word
    for (letter in word1) {
        // Check if the letter is present in both words
        if (letter in word2) {
            // Add the letter to the commonLetters list if it is not already present
            if (letter !in commonLetters) {
                commonLetters.add(letter)
            }
        }
    }

    // Return the list of common letters
    return commonLetters
}