/**
 * This function checks if a set of coordinates falls within the specified range.
 *
 * @param n Number of coordinates
 * @return A list containing the valid coordinates
 */
fun checkCoordinates(n: Int): List<Pair<Int, Int>> {

    val validCoordinates = mutableListOf<Pair<Int, Int>>()

    for (longitude in -180..180) {
        for (latitude in -90..90) {
            for (i in 0 until n) {
                print("Enter the x-coordinate for point ${i + 1}: ")
                val x = readLine()!!.toInt()
                print("Enter the y-coordinate for point ${i + 1}: ")
                val y = readLine()!!.toInt()

                if ((x >= longitude && x <= longitude + 1) && (y >= latitude && y <= latitude + 1)) {
                    validCoordinates.add(Pair(x, y))
                } else {
                    println("The point ($x, $y) lies outside the specified range.")
                }
            }
        }
    }

    return validCoordinates
}
/**
 * This function checks if a set of coordinates falls within the specified range.
 *
 * @param n Number of coordinates
 * @return A list containing the valid coordinates
 */
fun checkCoordinates(n: Int): List<Pair<Int, Int>> {
/**
 * This function checks if a set of coordinates falls within the specified range.
 *
 * @param n Number of coordinates
 * @return A list containing the valid coordinates
 */
fun checkCoordinates(n: Int): List<Pair<Int, Int>> {

    val validCoordinates = mutableListOf<Pair<Int, Int>>()

    for (longitude in -180..180) {
        for (latitude in -90..90) {
            for (i in 0 until n) {
                print("Enter the x-coordinate for point ${i + 1}: ")
                val x = readLine()!!.toInt()
                print("Enter the y-coordinate for point ${i + 1}: ")
                val y = readLine()!!.toInt()

                if ((x >= longitude && x <= longitude + 1) && (y >= latitude && y <= latitude + 1)) {
                    validCoordinates.add(Pair(x, y))
                } else {
                    println("The point ($x, $y) lies outside the specified range.")
                }
            }
        }
    }

    return validCoordinates
}