/**
 * This function takes two sets as arguments and returns a new set that contains the common elements of both sets.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements of set1 and set2.
 * @throws IllegalArgumentException If either set1 or set2 is not of type 'Set'.
 */
fun findCommonElements(set1: Set<Any>, set2: Set<Any>): Set<Any> {

    if (set1 !is Set<*>) {
        throw IllegalArgumentException("set1 should be of type 'Set'")
    }
    if (set2 !is Set<*>) {
        throw IllegalArgumentException("set2 should be of type 'Set'")
    }

    val commonElements = mutableSetOf<Any>()

    for (element in set1) {
        if (element in set2) {
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * This function takes two sets as arguments and returns a new set that contains the common elements of both sets.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements of set1 and set2.
 * @throws IllegalArgumentException If either set1 or set2 is not of type 'Set'.
 */
fun findCommonElements(set1: Set<Any>, set2: Set<Any>): Set<Any> {
/**
 * This function takes two sets as arguments and returns a new set that contains the common elements of both sets.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements of set1 and set2.
 * @throws IllegalArgumentException If either set1 or set2 is not of type 'Set'.
 */
fun findCommonElements(set1: Set<Any>, set2: Set<Any>): Set<Any> {

    if (set1 !is Set<*>) {
        throw IllegalArgumentException("set1 should be of type 'Set'")
    }
    if (set2 !is Set<*>) {
        throw IllegalArgumentException("set2 should be of type 'Set'")
    }

    val commonElements = mutableSetOf<Any>()

    for (element in set1) {
        if (element in set2) {
            commonElements.add(element)
        }
    }

    return commonElements
}