/**
 * Given a name, a list of indices, and a replacement string, replace the characters at the specified indices in the name
 * with the corresponding characters from the replacement string. Return the modified name.
 *
 * @param name The original name.
 * @param indices A list of indices where the characters need to be replaced.
 * @param replacement The string containing the replacement characters.
 * @return The modified name after replacing characters at the specified indices.
 *
 * Example:
 * replaceLetters("Carpenter", listOf(0, 2, 6), "mtp")
 * >> "mrtpermt"
 */
fun replaceLetters(name: String, indices: List<Int>, replacement: String): String {

    // Convert the name string to a list of characters
    val charList = name.toCharArray().toMutableList()

    // Iterate over the indices and replace the corresponding characters
    for (i in indices.indices) {
        charList[indices[i]] = replacement[i]
    }

    // Convert the list back to a string and return
    return charList.joinToString("")
}
/**
 * Given a name, a list of indices, and a replacement string, replace the characters at the specified indices in the name
 * with the corresponding characters from the replacement string. Return the modified name.
 *
 * @param name The original name.
 * @param indices A list of indices where the characters need to be replaced.
 * @param replacement The string containing the replacement characters.
 * @return The modified name after replacing characters at the specified indices.
 *
 * Example:
 * replaceLetters("Carpenter", listOf(0, 2, 6), "mtp")
 * >> "mrtpermt"
 */
fun replaceLetters(name: String, indices: List<Int>, replacement: String): String {
/**
 * Given a name, a list of indices, and a replacement string, replace the characters at the specified indices in the name
 * with the corresponding characters from the replacement string. Return the modified name.
 *
 * @param name The original name.
 * @param indices A list of indices where the characters need to be replaced.
 * @param replacement The string containing the replacement characters.
 * @return The modified name after replacing characters at the specified indices.
 *
 * Example:
 * replaceLetters("Carpenter", listOf(0, 2, 6), "mtp")
 * >> "mrtpermt"
 */
fun replaceLetters(name: String, indices: List<Int>, replacement: String): String {

    // Convert the name string to a list of characters
    val charList = name.toCharArray().toMutableList()

    // Iterate over the indices and replace the corresponding characters
    for (i in indices.indices) {
        charList[indices[i]] = replacement[i]
    }

    // Convert the list back to a string and return
    return charList.joinToString("")
}