/**
 * Given two sets, s1 and s2, find the intersection of the two sets using loops and tuple methods.
 *
 * @param s1 The first set.
 * @param s2 The second set.
 * @return The intersection of the two sets (common elements).
 *
 * Example:
 * '``
 * val s1 = setOf(1, 2, 3, 4, 5)
 * val s2 = setOf(4, 5, 6, 7, 8)
 * println(intersectionOfLoopsAndTuples(s1, s2)) // Output: [4, 5]
 * '``
 */
fun intersectionOfLoopsAndTuples(s1: Set<Int>, s2: Set<Int>): Set<Int> {

    // Convert sets to lists
    val s1List = s1.toList()
    val s2List = s2.toList()

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

    // Iterate over each element in the first list
    for (element in s1List) {
        // Check if the element exists in the second list
        if (element in s2List) {
            // Add the common element to the intersection set
            intersection.add(element)
        }
    }

    return intersection
}
/**
 * Given two sets, s1 and s2, find the intersection of the two sets using loops and tuple methods.
 *
 * @param s1 The first set.
 * @param s2 The second set.
 * @return The intersection of the two sets (common elements).
 *
 * Example:
 * '``
 * val s1 = setOf(1, 2, 3, 4, 5)
 * val s2 = setOf(4, 5, 6, 7, 8)
 * println(intersectionOfLoopsAndTuples(s1, s2)) // Output: [4, 5]
 * '``
 */
fun intersectionOfLoopsAndTuples(s1: Set<Int>, s2: Set<Int>): Set<Int> {
/**
 * Given two sets, s1 and s2, find the intersection of the two sets using loops and tuple methods.
 *
 * @param s1 The first set.
 * @param s2 The second set.
 * @return The intersection of the two sets (common elements).
 *
 * Example:
 * '``
 * val s1 = setOf(1, 2, 3, 4, 5)
 * val s2 = setOf(4, 5, 6, 7, 8)
 * println(intersectionOfLoopsAndTuples(s1, s2)) // Output: [4, 5]
 * '``
 */
fun intersectionOfLoopsAndTuples(s1: Set<Int>, s2: Set<Int>): Set<Int> {

    // Convert sets to lists
    val s1List = s1.toList()
    val s2List = s2.toList()

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

    // Iterate over each element in the first list
    for (element in s1List) {
        // Check if the element exists in the second list
        if (element in s2List) {
            // Add the common element to the intersection set
            intersection.add(element)
        }
    }

    return intersection
}