/**
 * This exercise aims to test your understanding of the intersection operation of sets along with the use of the method count().
 *
 * Write a function that takes two sets as input and returns the count of elements that are common to both sets.
 *
 * @param set1 First set containing elements.
 * @param set2 Second set containing elements.
 * @return Count of common elements between set1 and set2.
 */
fun intersectionCount(set1: Set<Any>, set2: Set<Any>): Int {

    // Calculate the intersection of set1 and set2
    val intersect = set1.intersect(set2)

    // Initialize a counter to keep track of common elements
    var count = 0

    // Iterate over each element in the intersect set
    for (element in intersect) {
        // Count the occurrence of the element in both sets and add to the count variable
        count += minOf(set1.count { it == element }, set2.count { it == element })
    }

    return count
}
/**
 * This exercise aims to test your understanding of the intersection operation of sets along with the use of the method count().
 *
 * Write a function that takes two sets as input and returns the count of elements that are common to both sets.
 *
 * @param set1 First set containing elements.
 * @param set2 Second set containing elements.
 * @return Count of common elements between set1 and set2.
 */
fun intersectionCount(set1: Set<Any>, set2: Set<Any>): Int {
/**
 * This exercise aims to test your understanding of the intersection operation of sets along with the use of the method count().
 *
 * Write a function that takes two sets as input and returns the count of elements that are common to both sets.
 *
 * @param set1 First set containing elements.
 * @param set2 Second set containing elements.
 * @return Count of common elements between set1 and set2.
 */
fun intersectionCount(set1: Set<Any>, set2: Set<Any>): Int {

    // Calculate the intersection of set1 and set2
    val intersect = set1.intersect(set2)

    // Initialize a counter to keep track of common elements
    var count = 0

    // Iterate over each element in the intersect set
    for (element in intersect) {
        // Count the occurrence of the element in both sets and add to the count variable
        count += minOf(set1.count { it == element }, set2.count { it == element })
    }

    return count
}