/**
 * This exercise requires you to modify a tuple within a dictionary.
 * Given a dictionary, a key, an old tuple value, and a new tuple value,
 * modify the dictionary by replacing the old tuple value with the new tuple value.
 * Return the modified dictionary.
 *
 * @param dictionary The original dictionary.
 * @param key The key within the dictionary to modify.
 * @param oldValue The tuple value to replace.
 * @param newValue The new tuple value to set.
 * @return The modified dictionary with the old tuple value replaced by the new tuple value.
 */
fun modifyTupleInDictionary(dictionary: MutableMap<String, List<Any>>, key: String, oldValue: List<Any>, newValue: List<Any>): MutableMap<String, List<Any>> {

    if (!dictionary.containsKey(key)) {
        return dictionary
    }

    if (!dictionary[key]!!.contains(oldValue)) {
        return dictionary
    }

    dictionary[key] = dictionary[key]!!.map { if (it == oldValue) newValue else it }.toMutableList()

    return dictionary
}
/**
 * This exercise requires you to modify a tuple within a dictionary.
 * Given a dictionary, a key, an old tuple value, and a new tuple value,
 * modify the dictionary by replacing the old tuple value with the new tuple value.
 * Return the modified dictionary.
 *
 * @param dictionary The original dictionary.
 * @param key The key within the dictionary to modify.
 * @param oldValue The tuple value to replace.
 * @param newValue The new tuple value to set.
 * @return The modified dictionary with the old tuple value replaced by the new tuple value.
 */
fun modifyTupleInDictionary(dictionary: MutableMap<String, List<Any>>, key: String, oldValue: List<Any>, newValue: List<Any>): MutableMap<String, List<Any>> {
/**
 * This exercise requires you to modify a tuple within a dictionary.
 * Given a dictionary, a key, an old tuple value, and a new tuple value,
 * modify the dictionary by replacing the old tuple value with the new tuple value.
 * Return the modified dictionary.
 *
 * @param dictionary The original dictionary.
 * @param key The key within the dictionary to modify.
 * @param oldValue The tuple value to replace.
 * @param newValue The new tuple value to set.
 * @return The modified dictionary with the old tuple value replaced by the new tuple value.
 */
fun modifyTupleInDictionary(dictionary: MutableMap<String, List<Any>>, key: String, oldValue: List<Any>, newValue: List<Any>): MutableMap<String, List<Any>> {

    if (!dictionary.containsKey(key)) {
        return dictionary
    }

    if (!dictionary[key]!!.contains(oldValue)) {
        return dictionary
    }

    dictionary[key] = dictionary[key]!!.map { if (it == oldValue) newValue else it }.toMutableList()

    return dictionary
}