/**
 * This function takes two sets as input and returns the intersection of the two sets.
 *
 * @param set1 The first set
 * @param set2 The second set
 * @return The intersection of the two sets
 * @throws IllegalArgumentException If the inputs are not valid sets
 *
 * Example:
 * intersectionOfSets(setOf(1, 2, 3), setOf(2, 3, 4)) // returns setOf(2, 3)
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    if (set1.javaClass != HashSet::class.java || set2.javaClass != HashSet::class.java) {
        throw IllegalArgumentException("Input must be sets")
    }

    val intersection = mutableSetOf<Int>()
    for (element in set1) {
        if (element in set2) {
            intersection.add(element)
        }
    }

    return intersection
}
/**
 * This function takes two sets as input and returns the intersection of the two sets.
 *
 * @param set1 The first set
 * @param set2 The second set
 * @return The intersection of the two sets
 * @throws IllegalArgumentException If the inputs are not valid sets
 *
 * Example:
 * intersectionOfSets(setOf(1, 2, 3), setOf(2, 3, 4)) // returns setOf(2, 3)
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {
/**
 * This function takes two sets as input and returns the intersection of the two sets.
 *
 * @param set1 The first set
 * @param set2 The second set
 * @return The intersection of the two sets
 * @throws IllegalArgumentException If the inputs are not valid sets
 *
 * Example:
 * intersectionOfSets(setOf(1, 2, 3), setOf(2, 3, 4)) // returns setOf(2, 3)
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    if (set1.javaClass != HashSet::class.java || set2.javaClass != HashSet::class.java) {
        throw IllegalArgumentException("Input must be sets")
    }

    val intersection = mutableSetOf<Int>()
    for (element in set1) {
        if (element in set2) {
            intersection.add(element)
        }
    }

    return intersection
}