/**
 * Given a list of pairs representing patients, index of the patient to modify, and the new age,
 * modify the age of the specified patient in the list of pairs.
 *
 * @param patients A list of pairs representing patients. Each pair contains the patient's name (String) and age (Int).
 * @param index The index of the patient to modify.
 * @param age The new age to assign to the specified patient.
 * @return The updated list of pairs representing patients with the age modified.
 *
 * Example:
 * modifyPatientAge(listOf("John" to 25, "Alice" to 30, "Bob" to 40), 1, 35) --> listOf("John" to 25, "Alice" to 35, "Bob" to 40)
 */
fun modifyPatientAge(patients: List<Pair<String, Int>>, index: Int, age: Int): List<Pair<String, Int>> {

    // Access the specified patient's age using indexing
    val patient = patients[index]
    val (patientName, _) = patient

    // Modify the age of the patient using list methods
    val updatedPatients = patients.toMutableList()
    updatedPatients[index] = patientName to age

    return updatedPatients
}
/**
 * Given a list of pairs representing patients, index of the patient to modify, and the new age,
 * modify the age of the specified patient in the list of pairs.
 *
 * @param patients A list of pairs representing patients. Each pair contains the patient's name (String) and age (Int).
 * @param index The index of the patient to modify.
 * @param age The new age to assign to the specified patient.
 * @return The updated list of pairs representing patients with the age modified.
 *
 * Example:
 * modifyPatientAge(listOf("John" to 25, "Alice" to 30, "Bob" to 40), 1, 35) --> listOf("John" to 25, "Alice" to 35, "Bob" to 40)
 */
fun modifyPatientAge(patients: List<Pair<String, Int>>, index: Int, age: Int): List<Pair<String, Int>> {
/**
 * Given a list of pairs representing patients, index of the patient to modify, and the new age,
 * modify the age of the specified patient in the list of pairs.
 *
 * @param patients A list of pairs representing patients. Each pair contains the patient's name (String) and age (Int).
 * @param index The index of the patient to modify.
 * @param age The new age to assign to the specified patient.
 * @return The updated list of pairs representing patients with the age modified.
 *
 * Example:
 * modifyPatientAge(listOf("John" to 25, "Alice" to 30, "Bob" to 40), 1, 35) --> listOf("John" to 25, "Alice" to 35, "Bob" to 40)
 */
fun modifyPatientAge(patients: List<Pair<String, Int>>, index: Int, age: Int): List<Pair<String, Int>> {

    // Access the specified patient's age using indexing
    val patient = patients[index]
    val (patientName, _) = patient

    // Modify the age of the patient using list methods
    val updatedPatients = patients.toMutableList()
    updatedPatients[index] = patientName to age

    return updatedPatients
}