/**
 * Given a dictionary and a string, modify the dictionary in such a way that each key in the dictionary
 * is updated with a list containing all the indexes at which the corresponding character appears in the string.
 *
 * @param dictionary The dictionary containing keys to be updated.
 * @param string The string to be searched for characters.
 * @return The modified dictionary.
 */
fun modifyDictionaryWithStringChars(dictionary: MutableMap<Char, MutableList<Int>>, string: String): MutableMap<Char, MutableList<Int>> {

    // Iterate through each key in the dictionary
    for (key in dictionary.keys.toList()) {
        // Initialize an empty list to store the indexes of the character in the string
        val indexes = mutableListOf<Int>()

        // Iterate through each character in the string
        for (i in string.indices) {
            // If the character at the current index matches the one in the dictionary key,
            // add the index to the list
            if (string[i] == key) {
                indexes.add(i)
            }
        }

        // Update the dictionary value at the current key with the list of indexes
        dictionary[key] = indexes
    }

    return dictionary
}

// Example usage
val myDict = mutableMapOf('a' to mutableListOf<Int>(), 'b' to mutableListOf<Int>())
/**
 * Given a dictionary and a string, modify the dictionary in such a way that each key in the dictionary
 * is updated with a list containing all the indexes at which the corresponding character appears in the string.
 *
 * @param dictionary The dictionary containing keys to be updated.
 * @param string The string to be searched for characters.
 * @return The modified dictionary.
 */
fun modifyDictionaryWithStringChars(dictionary: MutableMap<Char, MutableList<Int>>, string: String): MutableMap<Char, MutableList<Int>> {
/**
 * Given a dictionary and a string, modify the dictionary in such a way that each key in the dictionary
 * is updated with a list containing all the indexes at which the corresponding character appears in the string.
 *
 * @param dictionary The dictionary containing keys to be updated.
 * @param string The string to be searched for characters.
 * @return The modified dictionary.
 */
fun modifyDictionaryWithStringChars(dictionary: MutableMap<Char, MutableList<Int>>, string: String): MutableMap<Char, MutableList<Int>> {

    // Iterate through each key in the dictionary
    for (key in dictionary.keys.toList()) {
        // Initialize an empty list to store the indexes of the character in the string
        val indexes = mutableListOf<Int>()

        // Iterate through each character in the string
        for (i in string.indices) {
            // If the character at the current index matches the one in the dictionary key,
            // add the index to the list
            if (string[i] == key) {
                indexes.add(i)
            }
        }

        // Update the dictionary value at the current key with the list of indexes
        dictionary[key] = indexes
    }

    return dictionary
}

// Example usage
val myDict = mutableMapOf('a' to mutableListOf<Int>(), 'b' to mutableListOf<Int>())