/**
 * Given two sets, find the common elements between them.
 *
 * @param set1 First set of elements
 * @param set2 Second set of elements
 * @return Set containing the common elements
 * @throws AssertionError If either set is empty
 *
 * Example:
 * commonElements(setOf(1, 2, 3), setOf(2, 3, 4)) => setOf(2, 3)
 */
fun commonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    require(set1.isNotEmpty() && set2.isNotEmpty()) { "Both sets must have at least one element" }

    // Find the common elements between the sets and return them in a new set
    val common = mutableSetOf<Int>()
    for (element in set1) {
        if (element in set2) {
            common.add(element)
        }
    }

    return common
}
/**
 * Given two sets, find the common elements between them.
 *
 * @param set1 First set of elements
 * @param set2 Second set of elements
 * @return Set containing the common elements
 * @throws AssertionError If either set is empty
 *
 * Example:
 * commonElements(setOf(1, 2, 3), setOf(2, 3, 4)) => setOf(2, 3)
 */
fun commonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {
/**
 * Given two sets, find the common elements between them.
 *
 * @param set1 First set of elements
 * @param set2 Second set of elements
 * @return Set containing the common elements
 * @throws AssertionError If either set is empty
 *
 * Example:
 * commonElements(setOf(1, 2, 3), setOf(2, 3, 4)) => setOf(2, 3)
 */
fun commonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    require(set1.isNotEmpty() && set2.isNotEmpty()) { "Both sets must have at least one element" }

    // Find the common elements between the sets and return them in a new set
    val common = mutableSetOf<Int>()
    for (element in set1) {
        if (element in set2) {
            common.add(element)
        }
    }

    return common
}