/**
 * Given a text and a list of characters, create a function that replaces all occurrences of each character in the text
 * with its lowercase version using list comprehensions.
 *
 * @param text A string representing the original text.
 * @param characters A list of characters to be replaced.
 * @return A new string with replaced characters.
 *
 * Example:
 * replaceCharacters("Hello World", listOf('H', 'o')) -> "hello wOrld"
 */
fun replaceCharacters(text: String, characters: List<Char>): String {

    // Convert text to a list of characters
    val charList = text.toList()

    // Use list comprehension to replace characters and convert them to lowercase
    val newCharList = charList.map { if (it in characters) it.toLowerCase() else it }

    // Join the characters back to form a string
    val newText = newCharList.joinToString("")

    return newText
}
/**
 * Given a text and a list of characters, create a function that replaces all occurrences of each character in the text
 * with its lowercase version using list comprehensions.
 *
 * @param text A string representing the original text.
 * @param characters A list of characters to be replaced.
 * @return A new string with replaced characters.
 *
 * Example:
 * replaceCharacters("Hello World", listOf('H', 'o')) -> "hello wOrld"
 */
fun replaceCharacters(text: String, characters: List<Char>): String {
/**
 * Given a text and a list of characters, create a function that replaces all occurrences of each character in the text
 * with its lowercase version using list comprehensions.
 *
 * @param text A string representing the original text.
 * @param characters A list of characters to be replaced.
 * @return A new string with replaced characters.
 *
 * Example:
 * replaceCharacters("Hello World", listOf('H', 'o')) -> "hello wOrld"
 */
fun replaceCharacters(text: String, characters: List<Char>): String {

    // Convert text to a list of characters
    val charList = text.toList()

    // Use list comprehension to replace characters and convert them to lowercase
    val newCharList = charList.map { if (it in characters) it.toLowerCase() else it }

    // Join the characters back to form a string
    val newText = newCharList.joinToString("")

    return newText
}