/**
 * This exercise requires you to find the common elements between two sets.
 *
 * Write a function that takes in two sets, set1 and set2, and returns a new set
 * containing the elements that are common in both sets.
 *
 * For example,
 * If set1 = setOf(1, 2, 3, 4) and set2 = setOf(3, 4, 5, 6), the function should return setOf(3, 4).
 *
 * Your task is to complete the code within the function below.
 */
fun findCommonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    // Initialize an empty set to store the common elements
    val commonElements = mutableSetOf<Int>()

    // Use nested loops to iterate through each element of set1 and set2
    for (element1 in set1) {
        for (element2 in set2) {
            // If an element in set1 matches an element in set2, add it to the commonElements set
            if (element1 == element2) {
                commonElements.add(element1)
            }
        }
    }

    // Return the set containing the common elements
    return commonElements
}
/**
 * This exercise requires you to find the common elements between two sets.
 *
 * Write a function that takes in two sets, set1 and set2, and returns a new set
 * containing the elements that are common in both sets.
 *
 * For example,
 * If set1 = setOf(1, 2, 3, 4) and set2 = setOf(3, 4, 5, 6), the function should return setOf(3, 4).
 *
 * Your task is to complete the code within the function below.
 */
fun findCommonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {
/**
 * This exercise requires you to find the common elements between two sets.
 *
 * Write a function that takes in two sets, set1 and set2, and returns a new set
 * containing the elements that are common in both sets.
 *
 * For example,
 * If set1 = setOf(1, 2, 3, 4) and set2 = setOf(3, 4, 5, 6), the function should return setOf(3, 4).
 *
 * Your task is to complete the code within the function below.
 */
fun findCommonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    // Initialize an empty set to store the common elements
    val commonElements = mutableSetOf<Int>()

    // Use nested loops to iterate through each element of set1 and set2
    for (element1 in set1) {
        for (element2 in set2) {
            // If an element in set1 matches an element in set2, add it to the commonElements set
            if (element1 == element2) {
                commonElements.add(element1)
            }
        }
    }

    // Return the set containing the common elements
    return commonElements
}