/**
 * Replace certain characters in the given string with lists of their indices.
 *
 * @param data A string containing characters to be replaced.
 * @param chars A string of characters to be searched in the string.
 * @param replacement A list containing the elements to replace the characters.
 * @return The modified string after replacing the characters.
 *
 * Example:
 * replaceCharsWithLists("Hello, world!", "lH", listOf("L", listOf(2, 9)))
 * Output: "Le[2, 9][2, 9]o, wor[2, 9]d!"
 */
fun replaceCharsWithLists(data: String, chars: String, replacement: List<Any>): String {

    val result = mutableListOf<Any>()
    for (char in data) {
        if (char.toString() in chars) {
            result.add(replacement[chars.indexOf(char.toString())])
        } else {
            result.add(char)
        }
    }
    return result.joinToString("")
}
/**
 * Replace certain characters in the given string with lists of their indices.
 *
 * @param data A string containing characters to be replaced.
 * @param chars A string of characters to be searched in the string.
 * @param replacement A list containing the elements to replace the characters.
 * @return The modified string after replacing the characters.
 *
 * Example:
 * replaceCharsWithLists("Hello, world!", "lH", listOf("L", listOf(2, 9)))
 * Output: "Le[2, 9][2, 9]o, wor[2, 9]d!"
 */
fun replaceCharsWithLists(data: String, chars: String, replacement: List<Any>): String {
/**
 * Replace certain characters in the given string with lists of their indices.
 *
 * @param data A string containing characters to be replaced.
 * @param chars A string of characters to be searched in the string.
 * @param replacement A list containing the elements to replace the characters.
 * @return The modified string after replacing the characters.
 *
 * Example:
 * replaceCharsWithLists("Hello, world!", "lH", listOf("L", listOf(2, 9)))
 * Output: "Le[2, 9][2, 9]o, wor[2, 9]d!"
 */
fun replaceCharsWithLists(data: String, chars: String, replacement: List<Any>): String {

    val result = mutableListOf<Any>()
    for (char in data) {
        if (char.toString() in chars) {
            result.add(replacement[chars.indexOf(char.toString())])
        } else {
            result.add(char)
        }
    }
    return result.joinToString("")
}