/**
 * This function calculates the intersection of two number lines represented as pairs.
 *
 * @param a The first number line represented as a pair.
 * @param b The second number line represented as a pair.
 * @return The intersection of the two number lines represented as a pair.
 * @throws IllegalArgumentException If the input arguments are not pairs or if any pair has more or less than two elements.
 */
fun calculateIntersection(a: Pair<Int, Int>, b: Pair<Int, Int>): Pair<Int, Int> {

    if (a !is Pair<*, *> || b !is Pair<*, *>) {
        throw IllegalArgumentException("Input arguments must be pairs.")
    }

    if (a.toList().size != 2 || b.toList().size != 2) {
        throw IllegalArgumentException("Input pairs must have two elements.")
    }

    val result = Pair(maxOf(a.first, b.first), minOf(a.second, b.second))

    return result
}
/**
 * This function calculates the intersection of two number lines represented as pairs.
 *
 * @param a The first number line represented as a pair.
 * @param b The second number line represented as a pair.
 * @return The intersection of the two number lines represented as a pair.
 * @throws IllegalArgumentException If the input arguments are not pairs or if any pair has more or less than two elements.
 */
fun calculateIntersection(a: Pair<Int, Int>, b: Pair<Int, Int>): Pair<Int, Int> {
/**
 * This function calculates the intersection of two number lines represented as pairs.
 *
 * @param a The first number line represented as a pair.
 * @param b The second number line represented as a pair.
 * @return The intersection of the two number lines represented as a pair.
 * @throws IllegalArgumentException If the input arguments are not pairs or if any pair has more or less than two elements.
 */
fun calculateIntersection(a: Pair<Int, Int>, b: Pair<Int, Int>): Pair<Int, Int> {

    if (a !is Pair<*, *> || b !is Pair<*, *>) {
        throw IllegalArgumentException("Input arguments must be pairs.")
    }

    if (a.toList().size != 2 || b.toList().size != 2) {
        throw IllegalArgumentException("Input pairs must have two elements.")
    }

    val result = Pair(maxOf(a.first, b.first), minOf(a.second, b.second))

    return result
}