/**
 * Given two pairs representing number line intervals, return the intersection of the intervals.
 *
 * @param t1 A pair representing the first number line interval
 * @param t2 A pair representing the second number line interval
 * @return A pair representing the intersection of the two intervals, or null if there is no intersection
 *
 * Example:
 * intersection(Pair(2, 8), Pair(5, 12)) // Output: Pair(5, 8)
 * intersection(Pair(10, 15), Pair(20, 25)) // Output: null
 */
fun intersection(t1: Pair<Int, Int>, t2: Pair<Int, Int>): Pair<Int, Int>? {

    // Check if there is no intersection
    if (t1.second < t2.first || t2.second < t1.first) {
        return null
    }

    // Calculate the start and end of the intersection
    val start = maxOf(t1.first, t2.first)
    val end = minOf(t1.second, t2.second)

    return Pair(start, end)
}
/**
 * Given two pairs representing number line intervals, return the intersection of the intervals.
 *
 * @param t1 A pair representing the first number line interval
 * @param t2 A pair representing the second number line interval
 * @return A pair representing the intersection of the two intervals, or null if there is no intersection
 *
 * Example:
 * intersection(Pair(2, 8), Pair(5, 12)) // Output: Pair(5, 8)
 * intersection(Pair(10, 15), Pair(20, 25)) // Output: null
 */
fun intersection(t1: Pair<Int, Int>, t2: Pair<Int, Int>): Pair<Int, Int>? {
/**
 * Given two pairs representing number line intervals, return the intersection of the intervals.
 *
 * @param t1 A pair representing the first number line interval
 * @param t2 A pair representing the second number line interval
 * @return A pair representing the intersection of the two intervals, or null if there is no intersection
 *
 * Example:
 * intersection(Pair(2, 8), Pair(5, 12)) // Output: Pair(5, 8)
 * intersection(Pair(10, 15), Pair(20, 25)) // Output: null
 */
fun intersection(t1: Pair<Int, Int>, t2: Pair<Int, Int>): Pair<Int, Int>? {

    // Check if there is no intersection
    if (t1.second < t2.first || t2.second < t1.first) {
        return null
    }

    // Calculate the start and end of the intersection
    val start = maxOf(t1.first, t2.first)
    val end = minOf(t1.second, t2.second)

    return Pair(start, end)
}