/**
 * This exercise focuses on the syntax of the ternary operator and comparing tuples.
 *
 * The task is to write a function that takes two geographic tuples as arguments and returns the intersection of both geographies.
 *
 * @param geography1 A tuple representing the coordinates of the first geographic location. It has the format (latitude, longitude).
 * @param geography2 A tuple representing the coordinates of the second geographic location. It has the format (latitude, longitude).
 * @return A tuple representing the intersection point if the two geographies intersect, otherwise return null.
 */
fun intersectionOfSyntaxAndTuples(geography1: Pair<Double, Double>, geography2: Pair<Double, Double>): Pair<Double, Double>? {

    val (latitude1, longitude1) = geography1
    val (latitude2, longitude2) = geography2

    // Check if geographies are parallel
    if (latitude1 == latitude2) {
        return null
    }

    // Find the intersection point
    val intersectLatitude = (latitude2 - latitude1) / (longitude1 - longitude2) * (0 - longitude1) + latitude1

    // Check if intersection point is within longitude range of both geographies
    if ((intersectLatitude >= latitude1 && intersectLatitude >= latitude2) || (intersectLatitude <= latitude1 && intersectLatitude <= latitude2)) {
        return Pair(intersectLatitude, 0.0) // Assuming longitude of intersection point is 0.0
    }

    return null
}
/**
 * This exercise focuses on the syntax of the ternary operator and comparing tuples.
 *
 * The task is to write a function that takes two geographic tuples as arguments and returns the intersection of both geographies.
 *
 * @param geography1 A tuple representing the coordinates of the first geographic location. It has the format (latitude, longitude).
 * @param geography2 A tuple representing the coordinates of the second geographic location. It has the format (latitude, longitude).
 * @return A tuple representing the intersection point if the two geographies intersect, otherwise return null.
 */
fun intersectionOfSyntaxAndTuples(geography1: Pair<Double, Double>, geography2: Pair<Double, Double>): Pair<Double, Double>? {
/**
 * This exercise focuses on the syntax of the ternary operator and comparing tuples.
 *
 * The task is to write a function that takes two geographic tuples as arguments and returns the intersection of both geographies.
 *
 * @param geography1 A tuple representing the coordinates of the first geographic location. It has the format (latitude, longitude).
 * @param geography2 A tuple representing the coordinates of the second geographic location. It has the format (latitude, longitude).
 * @return A tuple representing the intersection point if the two geographies intersect, otherwise return null.
 */
fun intersectionOfSyntaxAndTuples(geography1: Pair<Double, Double>, geography2: Pair<Double, Double>): Pair<Double, Double>? {

    val (latitude1, longitude1) = geography1
    val (latitude2, longitude2) = geography2

    // Check if geographies are parallel
    if (latitude1 == latitude2) {
        return null
    }

    // Find the intersection point
    val intersectLatitude = (latitude2 - latitude1) / (longitude1 - longitude2) * (0 - longitude1) + latitude1

    // Check if intersection point is within longitude range of both geographies
    if ((intersectLatitude >= latitude1 && intersectLatitude >= latitude2) || (intersectLatitude <= latitude1 && intersectLatitude <= latitude2)) {
        return Pair(intersectLatitude, 0.0) // Assuming longitude of intersection point is 0.0
    }

    return null
}