/**
 * Given a start and end value for a range, and an iterable, find the common elements between the range and the iterable.
 *
 * @param rangeStart The starting value of the range.
 * @param rangeEnd The ending value of the range (exclusive).
 * @param iterable The iterable to compare with the range.
 * @return A list of elements that are common between the range and the iterable.
 */
fun intersection(rangeStart: Int, rangeEnd: Int, iterable: Iterable<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (value in iterable) {
        if (value in rangeStart until rangeEnd) {
            commonElements.add(value)
        }
    }
    return commonElements
}

// Uncomment the below code to verify the solution

// val rangeValues = 5 until 15
// val iterableValues = listOf(3, 4, 8, 12, 16, 20)
// println(intersection(5, 15, iterableValues))  // Output: [8, 12]
/**
 * Given a start and end value for a range, and an iterable, find the common elements between the range and the iterable.
 *
 * @param rangeStart The starting value of the range.
 * @param rangeEnd The ending value of the range (exclusive).
 * @param iterable The iterable to compare with the range.
 * @return A list of elements that are common between the range and the iterable.
 */
fun intersection(rangeStart: Int, rangeEnd: Int, iterable: Iterable<Int>): List<Int> {
/**
 * Given a start and end value for a range, and an iterable, find the common elements between the range and the iterable.
 *
 * @param rangeStart The starting value of the range.
 * @param rangeEnd The ending value of the range (exclusive).
 * @param iterable The iterable to compare with the range.
 * @return A list of elements that are common between the range and the iterable.
 */
fun intersection(rangeStart: Int, rangeEnd: Int, iterable: Iterable<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (value in iterable) {
        if (value in rangeStart until rangeEnd) {
            commonElements.add(value)
        }
    }
    return commonElements
}

// Uncomment the below code to verify the solution

// val rangeValues = 5 until 15
// val iterableValues = listOf(3, 4, 8, 12, 16, 20)
// println(intersection(5, 15, iterableValues))  // Output: [8, 12]