/**
 * This exercise requires writing a function that finds the index of the intersection between two sets.
 *
 * @param set1 The first set to calculate intersection.
 * @param set2 The second set to calculate intersection.
 * @return The index of the intersection between the two sets.
 *
 * Note:
 * - The function assumes that both sets have at least one common element.
 * - The sets can contain any data type.
 *
 * Example:
 * intersectionIndex(setOf(1, 2, 3, 4), setOf(5, 6, 3, 7, 2)) should return 2 because the intersection element '2' is at index 2 in set1.
 *
 * Difficulty: ★★★★★
 */
fun intersectionIndex(set1: Set<Any>, set2: Set<Any>): Int {

    // Convert the sets to lists to access their indices
    val set1List = set1.toList()
    val set2List = set2.toList()

    // Find the intersection element
    val intersectionElement = set1.intersect(set2).first()

    // Find the index of the intersection element in set1
    val intersectionIndex = set1List.indexOf(intersectionElement)

    return intersectionIndex
}
/**
 * This exercise requires writing a function that finds the index of the intersection between two sets.
 *
 * @param set1 The first set to calculate intersection.
 * @param set2 The second set to calculate intersection.
 * @return The index of the intersection between the two sets.
 *
 * Note:
 * - The function assumes that both sets have at least one common element.
 * - The sets can contain any data type.
 *
 * Example:
 * intersectionIndex(setOf(1, 2, 3, 4), setOf(5, 6, 3, 7, 2)) should return 2 because the intersection element '2' is at index 2 in set1.
 *
 * Difficulty: ★★★★★
 */
fun intersectionIndex(set1: Set<Any>, set2: Set<Any>): Int {
/**
 * This exercise requires writing a function that finds the index of the intersection between two sets.
 *
 * @param set1 The first set to calculate intersection.
 * @param set2 The second set to calculate intersection.
 * @return The index of the intersection between the two sets.
 *
 * Note:
 * - The function assumes that both sets have at least one common element.
 * - The sets can contain any data type.
 *
 * Example:
 * intersectionIndex(setOf(1, 2, 3, 4), setOf(5, 6, 3, 7, 2)) should return 2 because the intersection element '2' is at index 2 in set1.
 *
 * Difficulty: ★★★★★
 */
fun intersectionIndex(set1: Set<Any>, set2: Set<Any>): Int {

    // Convert the sets to lists to access their indices
    val set1List = set1.toList()
    val set2List = set2.toList()

    // Find the intersection element
    val intersectionElement = set1.intersect(set2).first()

    // Find the index of the intersection element in set1
    val intersectionIndex = set1List.indexOf(intersectionElement)

    return intersectionIndex
}