/**
 * This function takes two sets as input and returns their intersection.
 * The intersection of two sets A and B is the set of elements that are common to both A and B.
 *
 * @param set1 First set of elements.
 * @param set2 Second set of elements.
 * @return The intersection of set1 and set2.
 */
fun intersectionSets(set1: Set<Any>, set2: Set<Any>): Set<Any> {

    // Check if the given inputs are sets
    if (set1 !is Set<*> || set2 !is Set<*>) {
        throw IllegalArgumentException("Please provide valid sets as input")
    }

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

    // Loop through each element in set1
    for (element in set1) {
        // Check if the element is also present in set2
        if (element in set2) {
            // Add the element to the intersection set
            intersection.add(element)
        }
    }

    return intersection
}
/**
 * This function takes two sets as input and returns their intersection.
 * The intersection of two sets A and B is the set of elements that are common to both A and B.
 *
 * @param set1 First set of elements.
 * @param set2 Second set of elements.
 * @return The intersection of set1 and set2.
 */
fun intersectionSets(set1: Set<Any>, set2: Set<Any>): Set<Any> {
/**
 * This function takes two sets as input and returns their intersection.
 * The intersection of two sets A and B is the set of elements that are common to both A and B.
 *
 * @param set1 First set of elements.
 * @param set2 Second set of elements.
 * @return The intersection of set1 and set2.
 */
fun intersectionSets(set1: Set<Any>, set2: Set<Any>): Set<Any> {

    // Check if the given inputs are sets
    if (set1 !is Set<*> || set2 !is Set<*>) {
        throw IllegalArgumentException("Please provide valid sets as input")
    }

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

    // Loop through each element in set1
    for (element in set1) {
        // Check if the element is also present in set2
        if (element in set2) {
            // Add the element to the intersection set
            intersection.add(element)
        }
    }

    return intersection
}