/**
 * Find the intersection between two number intervals on a number line, given their start and end points.
 *
 * @param a The start point of the first interval.
 * @param b The end point of the first interval.
 * @param c The start point of the second interval.
 * @param d The end point of the second interval.
 * @return The start and end points of the intersection interval if it exists, otherwise returns null.
 *
 * Note: This function assumes that the first interval is always smaller or equal to the second interval.
 */
fun findIntersection(a: Double, b: Double, c: Double, d: Double): Pair<Double, Double>? {

    // Find the intersection points
    if (c > b || a > d) {
        return null
    } else {
        val start = maxOf(a, c)
        val end = minOf(b, d)
        return Pair(start, end)
    }
}
/**
 * Find the intersection between two number intervals on a number line, given their start and end points.
 *
 * @param a The start point of the first interval.
 * @param b The end point of the first interval.
 * @param c The start point of the second interval.
 * @param d The end point of the second interval.
 * @return The start and end points of the intersection interval if it exists, otherwise returns null.
 *
 * Note: This function assumes that the first interval is always smaller or equal to the second interval.
 */
fun findIntersection(a: Double, b: Double, c: Double, d: Double): Pair<Double, Double>? {
/**
 * Find the intersection between two number intervals on a number line, given their start and end points.
 *
 * @param a The start point of the first interval.
 * @param b The end point of the first interval.
 * @param c The start point of the second interval.
 * @param d The end point of the second interval.
 * @return The start and end points of the intersection interval if it exists, otherwise returns null.
 *
 * Note: This function assumes that the first interval is always smaller or equal to the second interval.
 */
fun findIntersection(a: Double, b: Double, c: Double, d: Double): Pair<Double, Double>? {

    // Find the intersection points
    if (c > b || a > d) {
        return null
    } else {
        val start = maxOf(a, c)
        val end = minOf(b, d)
        return Pair(start, end)
    }
}