/**
 * Given a list of animals, remove all the sick animals from the list.
 * An animal will be considered sick if its weight is above 1000 grams.
 * Return the list of healthy animals.
 *
 * @param animals A list of animals, each represented as a Pair with the format (name, weight).
 * @return A list of healthy animals, without the sick ones.
 *
 * Example:
 * removeSickAnimals(listOf("Dog" to 500, "Cat" to 1500, "Horse" to 800, "Elephant" to 2000)) -> listOf("Dog" to 500, "Horse" to 800)
 */
fun removeSickAnimals(animals: List<Pair<String, Int>>): List<Pair<String, Int>> {

    var index = 0
    while (index < animals.size) {
        if (animals[index].second > 1000) {
            animals.toMutableList().apply { removeAt(index) }
        } else {
            index++
        }
    }
    return animals
}
/**
 * Given a list of animals, remove all the sick animals from the list.
 * An animal will be considered sick if its weight is above 1000 grams.
 * Return the list of healthy animals.
 *
 * @param animals A list of animals, each represented as a Pair with the format (name, weight).
 * @return A list of healthy animals, without the sick ones.
 *
 * Example:
 * removeSickAnimals(listOf("Dog" to 500, "Cat" to 1500, "Horse" to 800, "Elephant" to 2000)) -> listOf("Dog" to 500, "Horse" to 800)
 */
fun removeSickAnimals(animals: List<Pair<String, Int>>): List<Pair<String, Int>> {
/**
 * Given a list of animals, remove all the sick animals from the list.
 * An animal will be considered sick if its weight is above 1000 grams.
 * Return the list of healthy animals.
 *
 * @param animals A list of animals, each represented as a Pair with the format (name, weight).
 * @return A list of healthy animals, without the sick ones.
 *
 * Example:
 * removeSickAnimals(listOf("Dog" to 500, "Cat" to 1500, "Horse" to 800, "Elephant" to 2000)) -> listOf("Dog" to 500, "Horse" to 800)
 */
fun removeSickAnimals(animals: List<Pair<String, Int>>): List<Pair<String, Int>> {

    var index = 0
    while (index < animals.size) {
        if (animals[index].second > 1000) {
            animals.toMutableList().apply { removeAt(index) }
        } else {
            index++
        }
    }
    return animals
}