/**
 * This function takes a list of firefighters and the name of a firefighter as input.
 * It modifies the name of the firefighter in the list by replacing it with the name capitalized and reversed.
 * Finally, it returns the modified list of firefighters.
 *
 * @param personnel A list of firefighters' names.
 * @param name The name of the firefighter to be modified.
 * @return The modified list of firefighters' names.
 */
fun modifyPersonnel(personnel: MutableList<String>, name: String): List<String> {

    try {
        val index = personnel.indexOf(name)
        val modifiedName = name.reversed().capitalize()
        personnel[index] = modifiedName
    } catch (e: NoSuchElementException) {
        println("Firefighter not found in the personnel list.")
    }

    return personnel
}
/**
 * This function takes a list of firefighters and the name of a firefighter as input.
 * It modifies the name of the firefighter in the list by replacing it with the name capitalized and reversed.
 * Finally, it returns the modified list of firefighters.
 *
 * @param personnel A list of firefighters' names.
 * @param name The name of the firefighter to be modified.
 * @return The modified list of firefighters' names.
 */
fun modifyPersonnel(personnel: MutableList<String>, name: String): List<String> {
/**
 * This function takes a list of firefighters and the name of a firefighter as input.
 * It modifies the name of the firefighter in the list by replacing it with the name capitalized and reversed.
 * Finally, it returns the modified list of firefighters.
 *
 * @param personnel A list of firefighters' names.
 * @param name The name of the firefighter to be modified.
 * @return The modified list of firefighters' names.
 */
fun modifyPersonnel(personnel: MutableList<String>, name: String): List<String> {

    try {
        val index = personnel.indexOf(name)
        val modifiedName = name.reversed().capitalize()
        personnel[index] = modifiedName
    } catch (e: NoSuchElementException) {
        println("Firefighter not found in the personnel list.")
    }

    return personnel
}