/**
 * Given four integers a, b, c, and d, the function calculates the intersection of two sets of numbers.
 * The first set includes all integers from a to b (inclusive), while the second set includes all integers from c to d (inclusive).
 * The intersection is the range of integers that appear in both sets.
 *
 * @param a The lower bound of the first set.
 * @param b The upper bound of the first set.
 * @param c The lower bound of the second set.
 * @param d The upper bound of the second set.
 * @return The intersection (range) of integers that appear in both sets.
 */
fun calculateIntersection(a: Int, b: Int, c: Int, d: Int): IntRange? {

    // Check if the ranges do not overlap
    if (b < c || d < a) {
        return null
    }

    // Calculate the intersection
    val intersectionStart = maxOf(a, c)
    val intersectionEnd = minOf(b, d)

    return intersectionStart..intersectionEnd
}
/**
 * Given four integers a, b, c, and d, the function calculates the intersection of two sets of numbers.
 * The first set includes all integers from a to b (inclusive), while the second set includes all integers from c to d (inclusive).
 * The intersection is the range of integers that appear in both sets.
 *
 * @param a The lower bound of the first set.
 * @param b The upper bound of the first set.
 * @param c The lower bound of the second set.
 * @param d The upper bound of the second set.
 * @return The intersection (range) of integers that appear in both sets.
 */
fun calculateIntersection(a: Int, b: Int, c: Int, d: Int): IntRange? {
/**
 * Given four integers a, b, c, and d, the function calculates the intersection of two sets of numbers.
 * The first set includes all integers from a to b (inclusive), while the second set includes all integers from c to d (inclusive).
 * The intersection is the range of integers that appear in both sets.
 *
 * @param a The lower bound of the first set.
 * @param b The upper bound of the first set.
 * @param c The lower bound of the second set.
 * @param d The upper bound of the second set.
 * @return The intersection (range) of integers that appear in both sets.
 */
fun calculateIntersection(a: Int, b: Int, c: Int, d: Int): IntRange? {

    // Check if the ranges do not overlap
    if (b < c || d < a) {
        return null
    }

    // Calculate the intersection
    val intersectionStart = maxOf(a, c)
    val intersectionEnd = minOf(b, d)

    return intersectionStart..intersectionEnd
}