/**
 * Calculates the intersection between two number lines represented by [a, b] 
 * and [c, d] respectively.
 *
 * @param a Start point of the first number line.
 * @param b End point of the first number line.
 * @param c Start point of the second number line.
 * @param d End point of the second number line.
 * @return A Pair containing the start and end points of the intersection between 
 * the two number lines. Returns null if there is no intersection.
 * @throws IllegalArgumentException If the start point is greater than the end point for either 
 * number line.
 */
fun numberLineIntersection(a: Double, b: Double, c: Double, d: Double): Pair<Double, Double>? {

    if (a > b || c > d) {
        throw IllegalArgumentException("Start point should be less than or equal to end point.")
    }

    val intersectionStart = maxOf(a, c)
    val intersectionEnd = minOf(b, d)

    return if (intersectionStart <= intersectionEnd) {
        Pair(intersectionStart, intersectionEnd)
    } else {
        null
    }
}
/**
 * Calculates the intersection between two number lines represented by [a, b] 
 * and [c, d] respectively.
 *
 * @param a Start point of the first number line.
 * @param b End point of the first number line.
 * @param c Start point of the second number line.
 * @param d End point of the second number line.
 * @return A Pair containing the start and end points of the intersection between 
 * the two number lines. Returns null if there is no intersection.
 * @throws IllegalArgumentException If the start point is greater than the end point for either 
 * number line.
 */
fun numberLineIntersection(a: Double, b: Double, c: Double, d: Double): Pair<Double, Double>? {
/**
 * Calculates the intersection between two number lines represented by [a, b] 
 * and [c, d] respectively.
 *
 * @param a Start point of the first number line.
 * @param b End point of the first number line.
 * @param c Start point of the second number line.
 * @param d End point of the second number line.
 * @return A Pair containing the start and end points of the intersection between 
 * the two number lines. Returns null if there is no intersection.
 * @throws IllegalArgumentException If the start point is greater than the end point for either 
 * number line.
 */
fun numberLineIntersection(a: Double, b: Double, c: Double, d: Double): Pair<Double, Double>? {

    if (a > b || c > d) {
        throw IllegalArgumentException("Start point should be less than or equal to end point.")
    }

    val intersectionStart = maxOf(a, c)
    val intersectionEnd = minOf(b, d)

    return if (intersectionStart <= intersectionEnd) {
        Pair(intersectionStart, intersectionEnd)
    } else {
        null
    }
}