/**
 * This exercise requires accessing values in a dictionary and concatenating them.
 *
 * Given a dictionary with string values, the goal is to concatenate all the values
 * together and return the resulting string. However, the dictionary may also contain
 * nested dictionaries.
 *
 * Your task is to write a function that recursively iterates through all the values
 * in the dictionary, concatenates them, and returns the final string.
 *
 * @param dictionary A dictionary containing string values and possibly nested dictionaries.
 * @return The concatenated string.
 *
 * Example:
 * val dictionary = mapOf(
 *     "headline" to "Breaking News",
 *     "content" to "This is the latest update.",
 *     "author" to mapOf(
 *         "name" to "John Doe",
 *         "position" to "Senior Journalist"
 *     )
 * )
 * concatenateValues(dictionary) // Output: "Breaking NewsThis is the latest update.John DoeSenior Journalist"
 */
fun concatenateValues(dictionary: Map<String, Any>): String {

    var result = ""
    for (value in dictionary.values) {
        when (value) {
            is Map<*, *> -> result += concatenateValues(value as Map<String, Any>)
            is String -> result += value
        }
    }
    return result
}
/**
 * This exercise requires accessing values in a dictionary and concatenating them.
 *
 * Given a dictionary with string values, the goal is to concatenate all the values
 * together and return the resulting string. However, the dictionary may also contain
 * nested dictionaries.
 *
 * Your task is to write a function that recursively iterates through all the values
 * in the dictionary, concatenates them, and returns the final string.
 *
 * @param dictionary A dictionary containing string values and possibly nested dictionaries.
 * @return The concatenated string.
 *
 * Example:
 * val dictionary = mapOf(
 *     "headline" to "Breaking News",
 *     "content" to "This is the latest update.",
 *     "author" to mapOf(
 *         "name" to "John Doe",
 *         "position" to "Senior Journalist"
 *     )
 * )
 * concatenateValues(dictionary) // Output: "Breaking NewsThis is the latest update.John DoeSenior Journalist"
 */
fun concatenateValues(dictionary: Map<String, Any>): String {
/**
 * This exercise requires accessing values in a dictionary and concatenating them.
 *
 * Given a dictionary with string values, the goal is to concatenate all the values
 * together and return the resulting string. However, the dictionary may also contain
 * nested dictionaries.
 *
 * Your task is to write a function that recursively iterates through all the values
 * in the dictionary, concatenates them, and returns the final string.
 *
 * @param dictionary A dictionary containing string values and possibly nested dictionaries.
 * @return The concatenated string.
 *
 * Example:
 * val dictionary = mapOf(
 *     "headline" to "Breaking News",
 *     "content" to "This is the latest update.",
 *     "author" to mapOf(
 *         "name" to "John Doe",
 *         "position" to "Senior Journalist"
 *     )
 * )
 * concatenateValues(dictionary) // Output: "Breaking NewsThis is the latest update.John DoeSenior Journalist"
 */
fun concatenateValues(dictionary: Map<String, Any>): String {

    var result = ""
    for (value in dictionary.values) {
        when (value) {
            is Map<*, *> -> result += concatenateValues(value as Map<String, Any>)
            is String -> result += value
        }
    }
    return result
}