/**
 * This function takes in two sets and returns their intersection.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return The intersection of the two sets.
 */
fun intersectionOfSets(set1: Set<Any>, set2: Set<Any>): Set<Any> {

    // check if both inputs are sets
    if (set1 !is Set<*> || set2 !is Set<*>) {
        println("Both inputs must be sets!")
        return emptySet()
    }

    // check if either set is empty
    if (set1.isEmpty() || set2.isEmpty()) {
        println("Cannot compute intersection with empty set(s)!")
        return emptySet()
    }

    // create an empty set to store the intersection
    val intersection = mutableSetOf<Any>()

    // iterate through elements in set1
    for (elem in set1) {
        // check if the element is present in set2
        if (elem in set2) {
            // if yes, add it to the intersection set
            intersection.add(elem)
        }
    }

    return intersection
}
/**
 * This function takes in two sets and returns their intersection.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return The intersection of the two sets.
 */
fun intersectionOfSets(set1: Set<Any>, set2: Set<Any>): Set<Any> {
/**
 * This function takes in two sets and returns their intersection.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return The intersection of the two sets.
 */
fun intersectionOfSets(set1: Set<Any>, set2: Set<Any>): Set<Any> {

    // check if both inputs are sets
    if (set1 !is Set<*> || set2 !is Set<*>) {
        println("Both inputs must be sets!")
        return emptySet()
    }

    // check if either set is empty
    if (set1.isEmpty() || set2.isEmpty()) {
        println("Cannot compute intersection with empty set(s)!")
        return emptySet()
    }

    // create an empty set to store the intersection
    val intersection = mutableSetOf<Any>()

    // iterate through elements in set1
    for (elem in set1) {
        // check if the element is present in set2
        if (elem in set2) {
            // if yes, add it to the intersection set
            intersection.add(elem)
        }
    }

    return intersection
}