/**
 * This function takes in a list of people's ages and updates the age of all individuals who are currently
 * provided age with the new age.
 *
 * @param people A list of integers representing the ages of people.
 * @param age An integer representing the age that needs to be replaced.
 * @param newAge An integer representing the new age to be assigned.
 * @return A list of integers with all instances of the provided age replaced with the new age.
 */
fun updateAge(people: MutableList<Int>, age: Int, newAge: Int): List<Int> {

    // Handle empty list scenario
    if (people.isEmpty()) {
        return emptyList()
    }

    // Iterate through the list and replace the age
    for (i in people.indices) {
        if (people[i] == age) {
            // Replace the age with the newAge
            people[i] = newAge
        }
    }

    return people
}
/**
 * This function takes in a list of people's ages and updates the age of all individuals who are currently
 * provided age with the new age.
 *
 * @param people A list of integers representing the ages of people.
 * @param age An integer representing the age that needs to be replaced.
 * @param newAge An integer representing the new age to be assigned.
 * @return A list of integers with all instances of the provided age replaced with the new age.
 */
fun updateAge(people: MutableList<Int>, age: Int, newAge: Int): List<Int> {
/**
 * This function takes in a list of people's ages and updates the age of all individuals who are currently
 * provided age with the new age.
 *
 * @param people A list of integers representing the ages of people.
 * @param age An integer representing the age that needs to be replaced.
 * @param newAge An integer representing the new age to be assigned.
 * @return A list of integers with all instances of the provided age replaced with the new age.
 */
fun updateAge(people: MutableList<Int>, age: Int, newAge: Int): List<Int> {

    // Handle empty list scenario
    if (people.isEmpty()) {
        return emptyList()
    }

    // Iterate through the list and replace the age
    for (i in people.indices) {
        if (people[i] == age) {
            // Replace the age with the newAge
            people[i] = newAge
        }
    }

    return people
}