/**
 * Given a list of numbers and a range, this function finds the numbers within the range
 * that also intersect with the elements in the list using number line representation.
 *
 * @param numbers A list of numbers (integers or floats).
 * @param rangeStart The starting point of the range.
 * @param rangeEnd The ending point of the range.
 * @return A list of numbers that intersect with the range.
 */
fun findIntersectionNumbers(numbers: List<Double>, rangeStart: Double, rangeEnd: Double): List<Double> {

    // Ensure the rangeStart is smaller than rangeEnd
    var start = rangeStart
    var end = rangeEnd
    if (end < start) {
        start = rangeEnd
        end = rangeStart
    }

    val intersectingNumbers = mutableListOf<Double>()

    // Iterating over the numbers list to find the desired intersection
    for (number in numbers) {
        if (number >= start && number <= end) {
            intersectingNumbers.add(number)
        }
    }

    return intersectingNumbers
}

// Example usage of the function
val givenNumbers = listOf(14.5, 21.0, 9.0, 16.8, 7.0, 10.0)
val startRange = 8.0
val endRange = 15.0
/**
 * Given a list of numbers and a range, this function finds the numbers within the range
 * that also intersect with the elements in the list using number line representation.
 *
 * @param numbers A list of numbers (integers or floats).
 * @param rangeStart The starting point of the range.
 * @param rangeEnd The ending point of the range.
 * @return A list of numbers that intersect with the range.
 */
fun findIntersectionNumbers(numbers: List<Double>, rangeStart: Double, rangeEnd: Double): List<Double> {
/**
 * Given a list of numbers and a range, this function finds the numbers within the range
 * that also intersect with the elements in the list using number line representation.
 *
 * @param numbers A list of numbers (integers or floats).
 * @param rangeStart The starting point of the range.
 * @param rangeEnd The ending point of the range.
 * @return A list of numbers that intersect with the range.
 */
fun findIntersectionNumbers(numbers: List<Double>, rangeStart: Double, rangeEnd: Double): List<Double> {

    // Ensure the rangeStart is smaller than rangeEnd
    var start = rangeStart
    var end = rangeEnd
    if (end < start) {
        start = rangeEnd
        end = rangeStart
    }

    val intersectingNumbers = mutableListOf<Double>()

    // Iterating over the numbers list to find the desired intersection
    for (number in numbers) {
        if (number >= start && number <= end) {
            intersectingNumbers.add(number)
        }
    }

    return intersectingNumbers
}

// Example usage of the function
val givenNumbers = listOf(14.5, 21.0, 9.0, 16.8, 7.0, 10.0)
val startRange = 8.0
val endRange = 15.0