/**
 * Given a dictionary and a word, this function finds the number of common letters between each word in the dictionary
 * and the given word using a while loop.
 *
 * @param dictionary A list of words in the dictionary.
 * @param word A word for which the common letters need to be found.
 * @return The total number of common letters found.
 */
fun intersectionCommonLetters(dictionary: List<String>, word: String): Int {

    var i = 0
    var commonLetters = 0

    // Iterate through each word in the dictionary
    while (i < dictionary.size) {
        var j = 0

        // Check each letter in the word with each letter in the given word
        while (j < dictionary[i].length) {
            if (dictionary[i][j] in word) {
                commonLetters++
            }
            j++
        }
        i++
    }

    return commonLetters
}

// Example usage
/**
 * Given a dictionary and a word, this function finds the number of common letters between each word in the dictionary
 * and the given word using a while loop.
 *
 * @param dictionary A list of words in the dictionary.
 * @param word A word for which the common letters need to be found.
 * @return The total number of common letters found.
 */
fun intersectionCommonLetters(dictionary: List<String>, word: String): Int {
/**
 * Given a dictionary and a word, this function finds the number of common letters between each word in the dictionary
 * and the given word using a while loop.
 *
 * @param dictionary A list of words in the dictionary.
 * @param word A word for which the common letters need to be found.
 * @return The total number of common letters found.
 */
fun intersectionCommonLetters(dictionary: List<String>, word: String): Int {

    var i = 0
    var commonLetters = 0

    // Iterate through each word in the dictionary
    while (i < dictionary.size) {
        var j = 0

        // Check each letter in the word with each letter in the given word
        while (j < dictionary[i].length) {
            if (dictionary[i][j] in word) {
                commonLetters++
            }
            j++
        }
        i++
    }

    return commonLetters
}

// Example usage