/**
 * In this exercise, you need to replace certain elements in a text based on a given dictionary of replacements.
 *
 * @param data The input text in which replacements need to be made.
 * @param replaceMap A dictionary containing the words to be replaced as keys and their corresponding replacement as values.
 * @return The modified text after replacing the specified words as per the dictionary.
 */
fun replaceText(data: String, replaceMap: Map<String, String>): String {

    var result = ""
    val words = data.split(" ")
    for (word in words) {
        for ((key, value) in replaceMap) {
            if (word == key) {
                result += "$value "
                break
            }
        }
        if (word !in replaceMap.keys) {
            result += "$word "
        }
    }
    return result.trim()
}
/**
 * In this exercise, you need to replace certain elements in a text based on a given dictionary of replacements.
 *
 * @param data The input text in which replacements need to be made.
 * @param replaceMap A dictionary containing the words to be replaced as keys and their corresponding replacement as values.
 * @return The modified text after replacing the specified words as per the dictionary.
 */
fun replaceText(data: String, replaceMap: Map<String, String>): String {
/**
 * In this exercise, you need to replace certain elements in a text based on a given dictionary of replacements.
 *
 * @param data The input text in which replacements need to be made.
 * @param replaceMap A dictionary containing the words to be replaced as keys and their corresponding replacement as values.
 * @return The modified text after replacing the specified words as per the dictionary.
 */
fun replaceText(data: String, replaceMap: Map<String, String>): String {

    var result = ""
    val words = data.split(" ")
    for (word in words) {
        for ((key, value) in replaceMap) {
            if (word == key) {
                result += "$value "
                break
            }
        }
        if (word !in replaceMap.keys) {
            result += "$word "
        }
    }
    return result.trim()
}