/**
 * Given a starting and stopping point as well as a list of elements,
 * the function should append all even numbers between the start and stop
 * (inclusive) to the given list and then remove all negative numbers from it.
 *
 * @param start The starting point to generate the range.
 * @param stop The stopping point for the range.
 * @param elements The list to which elements should be appended and removed.
 * @return Updated list after appending even numbers and removing negative numbers.
 *
 * Example:
 * appendRemoveRange(3, 9, mutableListOf(10, -2, 5, -3)) returns [10, -2, 5, -3, 4, 6, 8]
 */
fun appendRemoveRange(start: Int, stop: Int, elements: MutableList<Int>): List<Int> {

    for (num in start..stop) {
        if (num % 2 == 0) {
            elements.add(num)
        }
    }

    return elements.filter { it >= 0 }
}
/**
 * Given a starting and stopping point as well as a list of elements,
 * the function should append all even numbers between the start and stop
 * (inclusive) to the given list and then remove all negative numbers from it.
 *
 * @param start The starting point to generate the range.
 * @param stop The stopping point for the range.
 * @param elements The list to which elements should be appended and removed.
 * @return Updated list after appending even numbers and removing negative numbers.
 *
 * Example:
 * appendRemoveRange(3, 9, mutableListOf(10, -2, 5, -3)) returns [10, -2, 5, -3, 4, 6, 8]
 */
fun appendRemoveRange(start: Int, stop: Int, elements: MutableList<Int>): List<Int> {
/**
 * Given a starting and stopping point as well as a list of elements,
 * the function should append all even numbers between the start and stop
 * (inclusive) to the given list and then remove all negative numbers from it.
 *
 * @param start The starting point to generate the range.
 * @param stop The stopping point for the range.
 * @param elements The list to which elements should be appended and removed.
 * @return Updated list after appending even numbers and removing negative numbers.
 *
 * Example:
 * appendRemoveRange(3, 9, mutableListOf(10, -2, 5, -3)) returns [10, -2, 5, -3, 4, 6, 8]
 */
fun appendRemoveRange(start: Int, stop: Int, elements: MutableList<Int>): List<Int> {

    for (num in start..stop) {
        if (num % 2 == 0) {
            elements.add(num)
        }
    }

    return elements.filter { it >= 0 }
}