/**
 * Given the coordinates of two rectangles, find the area of their intersection.
 *
 * @param rectangle1 Coordinates of the first rectangle, represented as (x1, y1, x2, y2)
 * @param rectangle2 Coordinates of the second rectangle, represented as (x1, y1, x2, y2)
 * @return Area of the intersection of the two rectangles
 */
fun findCommonArea(rectangle1: Pair<Int, Int>, rectangle2: Pair<Int, Int>): Float {

    val x1 = maxOf(rectangle1.first, rectangle2.first)
    val y1 = maxOf(rectangle1.second, rectangle2.second)
    val x2 = minOf(rectangle1.first, rectangle2.first)
    val y2 = minOf(rectangle1.second, rectangle2.second)

    if (x2 < x1 || y2 < y1) {
        // No overlap between the rectangles
        return 0.0f
    }

    val width = x2 - x1
    val height = y2 - y1

    return (width * height).toFloat()
}
/**
 * Given the coordinates of two rectangles, find the area of their intersection.
 *
 * @param rectangle1 Coordinates of the first rectangle, represented as (x1, y1, x2, y2)
 * @param rectangle2 Coordinates of the second rectangle, represented as (x1, y1, x2, y2)
 * @return Area of the intersection of the two rectangles
 */
fun findCommonArea(rectangle1: Pair<Int, Int>, rectangle2: Pair<Int, Int>): Float {
/**
 * Given the coordinates of two rectangles, find the area of their intersection.
 *
 * @param rectangle1 Coordinates of the first rectangle, represented as (x1, y1, x2, y2)
 * @param rectangle2 Coordinates of the second rectangle, represented as (x1, y1, x2, y2)
 * @return Area of the intersection of the two rectangles
 */
fun findCommonArea(rectangle1: Pair<Int, Int>, rectangle2: Pair<Int, Int>): Float {

    val x1 = maxOf(rectangle1.first, rectangle2.first)
    val y1 = maxOf(rectangle1.second, rectangle2.second)
    val x2 = minOf(rectangle1.first, rectangle2.first)
    val y2 = minOf(rectangle1.second, rectangle2.second)

    if (x2 < x1 || y2 < y1) {
        // No overlap between the rectangles
        return 0.0f
    }

    val width = x2 - x1
    val height = y2 - y1

    return (width * height).toFloat()
}