/**
 * Given a string, an index, and a character, replace the character at the specified index
 * with the given character.
 *
 * @param string The original string.
 * @param index The index at which the character should be replaced.
 * @param character The character to be inserted at the specified index.
 * @return The modified string.
 *
 * Example:
 * modifyString("hello", 1, "a") // Returns 'hallo'
 * modifyString("world", 3, "u") // Returns 'wourld'
 */
fun modifyString(string: String, index: Int, character: Char): String {

    // Convert string into a mutable list of characters
    val strList = string.toMutableList()

    // Replace the character at the given index with the provided character
    strList[index] = character

    // Convert the modified list back to a string
    return strList.joinToString("")
}
/**
 * Given a string, an index, and a character, replace the character at the specified index
 * with the given character.
 *
 * @param string The original string.
 * @param index The index at which the character should be replaced.
 * @param character The character to be inserted at the specified index.
 * @return The modified string.
 *
 * Example:
 * modifyString("hello", 1, "a") // Returns 'hallo'
 * modifyString("world", 3, "u") // Returns 'wourld'
 */
fun modifyString(string: String, index: Int, character: Char): String {
/**
 * Given a string, an index, and a character, replace the character at the specified index
 * with the given character.
 *
 * @param string The original string.
 * @param index The index at which the character should be replaced.
 * @param character The character to be inserted at the specified index.
 * @return The modified string.
 *
 * Example:
 * modifyString("hello", 1, "a") // Returns 'hallo'
 * modifyString("world", 3, "u") // Returns 'wourld'
 */
fun modifyString(string: String, index: Int, character: Char): String {

    // Convert string into a mutable list of characters
    val strList = string.toMutableList()

    // Replace the character at the given index with the provided character
    strList[index] = character

    // Convert the modified list back to a string
    return strList.joinToString("")
}