/**
 * This exercise requires you to find the intersection of two sets using slicing.
 *
 * Given two sets s1 and s2, write a Kotlin function that finds and returns the intersection of these two sets,
 * by slicing the elements from both sets and creating a new set.
 *
 * @param s1 First set
 * @param s2 Second set
 * @return Intersection of s1 and s2
 *
 * Example:
 * val s1 = setOf(1, 2, 3, 4, 5)
 * val s2 = setOf(4, 5, 6, 7, 8)
 * intersectionOfSlicingAndCreatingASet(s1, s2) // Output: setOf(4, 5)
 */
fun intersectionOfSlicingAndCreatingASet(s1: Set<Int>, s2: Set<Int>): Set<Int> {

    val intersectionSet = mutableSetOf<Int>()

    // Slicing the elements from both sets one by one
    for (elem in s1) {
        if (elem in s2) {
            intersectionSet.add(elem)
        }
    }

    return intersectionSet
}
/**
 * This exercise requires you to find the intersection of two sets using slicing.
 *
 * Given two sets s1 and s2, write a Kotlin function that finds and returns the intersection of these two sets,
 * by slicing the elements from both sets and creating a new set.
 *
 * @param s1 First set
 * @param s2 Second set
 * @return Intersection of s1 and s2
 *
 * Example:
 * val s1 = setOf(1, 2, 3, 4, 5)
 * val s2 = setOf(4, 5, 6, 7, 8)
 * intersectionOfSlicingAndCreatingASet(s1, s2) // Output: setOf(4, 5)
 */
fun intersectionOfSlicingAndCreatingASet(s1: Set<Int>, s2: Set<Int>): Set<Int> {
/**
 * This exercise requires you to find the intersection of two sets using slicing.
 *
 * Given two sets s1 and s2, write a Kotlin function that finds and returns the intersection of these two sets,
 * by slicing the elements from both sets and creating a new set.
 *
 * @param s1 First set
 * @param s2 Second set
 * @return Intersection of s1 and s2
 *
 * Example:
 * val s1 = setOf(1, 2, 3, 4, 5)
 * val s2 = setOf(4, 5, 6, 7, 8)
 * intersectionOfSlicingAndCreatingASet(s1, s2) // Output: setOf(4, 5)
 */
fun intersectionOfSlicingAndCreatingASet(s1: Set<Int>, s2: Set<Int>): Set<Int> {

    val intersectionSet = mutableSetOf<Int>()

    // Slicing the elements from both sets one by one
    for (elem in s1) {
        if (elem in s2) {
            intersectionSet.add(elem)
        }
    }

    return intersectionSet
}