/**
 * Calculate the intersection of two sets and perform operations on the resulting set.
 *
 * @param geologist The name of the geologist.
 * @param set1 The first set of integers.
 * @param set2 The second set of integers.
 * @return The resulting set after performing operations.
 * @throws IllegalArgumentException If either set1 or set2 is empty.
 */
fun intersectionOfOperations(geologist: String, set1: Set<Int>, set2: Set<Int>): Set<Int> {

    if (set1.isEmpty() || set2.isEmpty()) {
        throw IllegalArgumentException("Both sets must not be empty.")
    }

    // Calculate the intersection of the two sets
    val intersection = set1 intersect set2

    // Sort the intersection set in descending order
    val sortedIntersection = intersection.sortedDescending()

    // Perform operations on the resulting set
    val result = mutableSetOf<Int>()
    for (num in sortedIntersection) {
        // Check if the number is divisible by 2
        if (num % 2 == 0) {
            result.add(num * num)
        } else {
            result.add(num / 3)
        }
    }

    return result
}
/**
 * Calculate the intersection of two sets and perform operations on the resulting set.
 *
 * @param geologist The name of the geologist.
 * @param set1 The first set of integers.
 * @param set2 The second set of integers.
 * @return The resulting set after performing operations.
 * @throws IllegalArgumentException If either set1 or set2 is empty.
 */
fun intersectionOfOperations(geologist: String, set1: Set<Int>, set2: Set<Int>): Set<Int> {
/**
 * Calculate the intersection of two sets and perform operations on the resulting set.
 *
 * @param geologist The name of the geologist.
 * @param set1 The first set of integers.
 * @param set2 The second set of integers.
 * @return The resulting set after performing operations.
 * @throws IllegalArgumentException If either set1 or set2 is empty.
 */
fun intersectionOfOperations(geologist: String, set1: Set<Int>, set2: Set<Int>): Set<Int> {

    if (set1.isEmpty() || set2.isEmpty()) {
        throw IllegalArgumentException("Both sets must not be empty.")
    }

    // Calculate the intersection of the two sets
    val intersection = set1 intersect set2

    // Sort the intersection set in descending order
    val sortedIntersection = intersection.sortedDescending()

    // Perform operations on the resulting set
    val result = mutableSetOf<Int>()
    for (num in sortedIntersection) {
        // Check if the number is divisible by 2
        if (num % 2 == 0) {
            result.add(num * num)
        } else {
            result.add(num / 3)
        }
    }

    return result
}