/**
 * Finds the intersection of two intervals [a, b] and [c, d] on a number line.
 *
 * @param a Integer representing the start of the first interval.
 * @param b Integer representing the end of the first interval.
 * @param c Integer representing the start of the second interval.
 * @param d Integer representing the end of the second interval.
 * @return Pair<Int, Int> representing the boundaries of the intersection interval.
 * @throws IllegalArgumentException If the intervals do not intersect.
 */
fun getIntervalIntersection(a: Int, b: Int, c: Int, d: Int): Pair<Int, Int> {

    // Check if the intervals are valid
    if (a > b || c > d) {
        throw IllegalArgumentException("Invalid intervals provided.")
    }

    // Find the intersection
    val start = maxOf(a, c)
    val end = minOf(b, d)

    // Check if there is an intersection
    if (start > end) {
        throw IllegalArgumentException("No intersection between the intervals.")
    }

    return Pair(start, end)
}
/**
 * Finds the intersection of two intervals [a, b] and [c, d] on a number line.
 *
 * @param a Integer representing the start of the first interval.
 * @param b Integer representing the end of the first interval.
 * @param c Integer representing the start of the second interval.
 * @param d Integer representing the end of the second interval.
 * @return Pair<Int, Int> representing the boundaries of the intersection interval.
 * @throws IllegalArgumentException If the intervals do not intersect.
 */
fun getIntervalIntersection(a: Int, b: Int, c: Int, d: Int): Pair<Int, Int> {
/**
 * Finds the intersection of two intervals [a, b] and [c, d] on a number line.
 *
 * @param a Integer representing the start of the first interval.
 * @param b Integer representing the end of the first interval.
 * @param c Integer representing the start of the second interval.
 * @param d Integer representing the end of the second interval.
 * @return Pair<Int, Int> representing the boundaries of the intersection interval.
 * @throws IllegalArgumentException If the intervals do not intersect.
 */
fun getIntervalIntersection(a: Int, b: Int, c: Int, d: Int): Pair<Int, Int> {

    // Check if the intervals are valid
    if (a > b || c > d) {
        throw IllegalArgumentException("Invalid intervals provided.")
    }

    // Find the intersection
    val start = maxOf(a, c)
    val end = minOf(b, d)

    // Check if there is an intersection
    if (start > end) {
        throw IllegalArgumentException("No intersection between the intervals.")
    }

    return Pair(start, end)
}