/**
 * Given a list of Athlete objects, this function returns a new list that only contains the elite athletes.
 *
 * An athlete is considered elite if their age is greater than or equal to 30, and their sport is either "swimming"
 * or "running".
 *
 * Example:
 * ----------
 * val athletes = listOf(Athlete("John", 25, "swimming"), Athlete("Joe", 32, "cycling"), Athlete("Mary", 28, "running"))
 * val elite = findEliteAthletes(athletes)
 * println(elite)  // Output: [Athlete("Joe", 32, "cycling")]
 *
 * @param athletes A list of Athlete objects.
 * @return A list of Athlete objects representing the elite athletes.
 */
fun findEliteAthletes(athletes: List<Athlete>): List<Athlete> {

    val eliteAthletes = mutableListOf<Athlete>()

    for (athlete in athletes) {
        val isElite = athlete.age >= 30 && athlete.sport in listOf("swimming", "running")
        if (isElite) {
            eliteAthletes.add(athlete)
        }
    }

    return eliteAthletes
}

data class Athlete(val name: String, val age: Int, val sport: String)
/**
 * Given a list of Athlete objects, this function returns a new list that only contains the elite athletes.
 *
 * An athlete is considered elite if their age is greater than or equal to 30, and their sport is either "swimming"
 * or "running".
 *
 * Example:
 * ----------
 * val athletes = listOf(Athlete("John", 25, "swimming"), Athlete("Joe", 32, "cycling"), Athlete("Mary", 28, "running"))
 * val elite = findEliteAthletes(athletes)
 * println(elite)  // Output: [Athlete("Joe", 32, "cycling")]
 *
 * @param athletes A list of Athlete objects.
 * @return A list of Athlete objects representing the elite athletes.
 */
fun findEliteAthletes(athletes: List<Athlete>): List<Athlete> {
/**
 * Given a list of Athlete objects, this function returns a new list that only contains the elite athletes.
 *
 * An athlete is considered elite if their age is greater than or equal to 30, and their sport is either "swimming"
 * or "running".
 *
 * Example:
 * ----------
 * val athletes = listOf(Athlete("John", 25, "swimming"), Athlete("Joe", 32, "cycling"), Athlete("Mary", 28, "running"))
 * val elite = findEliteAthletes(athletes)
 * println(elite)  // Output: [Athlete("Joe", 32, "cycling")]
 *
 * @param athletes A list of Athlete objects.
 * @return A list of Athlete objects representing the elite athletes.
 */
fun findEliteAthletes(athletes: List<Athlete>): List<Athlete> {

    val eliteAthletes = mutableListOf<Athlete>()

    for (athlete in athletes) {
        val isElite = athlete.age >= 30 && athlete.sport in listOf("swimming", "running")
        if (isElite) {
            eliteAthletes.add(athlete)
        }
    }

    return eliteAthletes
}

data class Athlete(val name: String, val age: Int, val sport: String)