/**
 * Given a list and a set, this function finds the common elements between
 * them and returns a new list containing those elements.
 *
 * @param list1 A list of elements
 * @param set1 A set of elements
 * @return A new list containing the common elements between the list and set
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), setOf(2, 4, 6)) => [2, 4]
 */
fun findCommonElements(list1: List<Int>, set1: Set<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    list1.forEach { element ->
        if (element in set1) {
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Given a list and a set, this function finds the common elements between
 * them and returns a new list containing those elements.
 *
 * @param list1 A list of elements
 * @param set1 A set of elements
 * @return A new list containing the common elements between the list and set
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), setOf(2, 4, 6)) => [2, 4]
 */
fun findCommonElements(list1: List<Int>, set1: Set<Int>): List<Int> {
/**
 * Given a list and a set, this function finds the common elements between
 * them and returns a new list containing those elements.
 *
 * @param list1 A list of elements
 * @param set1 A set of elements
 * @return A new list containing the common elements between the list and set
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), setOf(2, 4, 6)) => [2, 4]
 */
fun findCommonElements(list1: List<Int>, set1: Set<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    list1.forEach { element ->
        if (element in set1) {
            commonElements.add(element)
        }
    }

    return commonElements
}