/**
 * Exercise:
 * You are given an original list and an original set. Your task is to create a copy of the list, and then loop through the set using a for loop. Each time you encounter an element in the set that is present in the original list, remove that element from the list.
 *
 * @param origList The original list.
 * @param origSet The original set.
 * @return The modified list after removing elements that match elements in the set.
 *
 * Example:
 * origList = [1, 2, 3, 4, 5, 6, 7, 8, 9]
 * origSet = setOf(2, 4, 6, 8)
 * copyAndLoop(origList, origSet) -> [1, 3, 5, 7, 9]
 */
fun copyAndLoop(origList: List<Int>, origSet: Set<Int>): List<Int> {

    // Create a copy of the original list
    val finalList = origList.toMutableList()

    for (element in origSet) {
        if (element in finalList) {
            finalList.remove(element)
        }
    }

    return finalList
}
/**
 * Exercise:
 * You are given an original list and an original set. Your task is to create a copy of the list, and then loop through the set using a for loop. Each time you encounter an element in the set that is present in the original list, remove that element from the list.
 *
 * @param origList The original list.
 * @param origSet The original set.
 * @return The modified list after removing elements that match elements in the set.
 *
 * Example:
 * origList = [1, 2, 3, 4, 5, 6, 7, 8, 9]
 * origSet = setOf(2, 4, 6, 8)
 * copyAndLoop(origList, origSet) -> [1, 3, 5, 7, 9]
 */
fun copyAndLoop(origList: List<Int>, origSet: Set<Int>): List<Int> {
/**
 * Exercise:
 * You are given an original list and an original set. Your task is to create a copy of the list, and then loop through the set using a for loop. Each time you encounter an element in the set that is present in the original list, remove that element from the list.
 *
 * @param origList The original list.
 * @param origSet The original set.
 * @return The modified list after removing elements that match elements in the set.
 *
 * Example:
 * origList = [1, 2, 3, 4, 5, 6, 7, 8, 9]
 * origSet = setOf(2, 4, 6, 8)
 * copyAndLoop(origList, origSet) -> [1, 3, 5, 7, 9]
 */
fun copyAndLoop(origList: List<Int>, origSet: Set<Int>): List<Int> {

    // Create a copy of the original list
    val finalList = origList.toMutableList()

    for (element in origSet) {
        if (element in finalList) {
            finalList.remove(element)
        }
    }

    return finalList
}