/**
 * Given a nurse's name as a string, an index as an integer, and a replacement string,
 * replace the character at the specified index with the replacement string and return
 * the resulting modified name.
 *
 * If the index is invalid (i.e., out of range for the name string), return the original name unchanged.
 *
 * @param name A string representing the nurse's name.
 * @param index An integer representing the index where the replacement should occur.
 * @param replacement A string representing the replacement text to be inserted.
 * @return The modified name after replacing the character at the specified index, or the original name if the index is invalid.
 */
fun replaceAndSlice(name: String, index: Int, replacement: String): String {

    if (index < 0 || index >= name.length) {
        return name
    }

    val newName = name.substring(0, index) + replacement + name.substring(index + 1)
    return newName
}
/**
 * Given a nurse's name as a string, an index as an integer, and a replacement string,
 * replace the character at the specified index with the replacement string and return
 * the resulting modified name.
 *
 * If the index is invalid (i.e., out of range for the name string), return the original name unchanged.
 *
 * @param name A string representing the nurse's name.
 * @param index An integer representing the index where the replacement should occur.
 * @param replacement A string representing the replacement text to be inserted.
 * @return The modified name after replacing the character at the specified index, or the original name if the index is invalid.
 */
fun replaceAndSlice(name: String, index: Int, replacement: String): String {
/**
 * Given a nurse's name as a string, an index as an integer, and a replacement string,
 * replace the character at the specified index with the replacement string and return
 * the resulting modified name.
 *
 * If the index is invalid (i.e., out of range for the name string), return the original name unchanged.
 *
 * @param name A string representing the nurse's name.
 * @param index An integer representing the index where the replacement should occur.
 * @param replacement A string representing the replacement text to be inserted.
 * @return The modified name after replacing the character at the specified index, or the original name if the index is invalid.
 */
fun replaceAndSlice(name: String, index: Int, replacement: String): String {

    if (index < 0 || index >= name.length) {
        return name
    }

    val newName = name.substring(0, index) + replacement + name.substring(index + 1)
    return newName
}