/**
 * Given a list of points in 3D space, find the nearest point neighboring the intersection.
 */
fun findNearestIntersection(points: List<Triple<Int, Int, Int>>): Triple<Int, Int, Int>? {

    var closestPoint: Triple<Int, Int, Int>? = null
    var minDistance = Double.POSITIVE_INFINITY

    for (point in points) {
        if (point == null) {
            continue
        }

        // Calculate the distance from the origin (0, 0, 0)
        val distance = Math.sqrt((point.first * point.first + point.second * point.second + point.third * point.third).toDouble())

        if (distance != 0.0 && distance < minDistance) {
            minDistance = distance
            closestPoint = point
        }
    }

    return closestPoint
}
/**
 * Given a list of points in 3D space, find the nearest point neighboring the intersection.
 */
fun findNearestIntersection(points: List<Triple<Int, Int, Int>>): Triple<Int, Int, Int>? {
/**
 * Given a list of points in 3D space, find the nearest point neighboring the intersection.
 */
fun findNearestIntersection(points: List<Triple<Int, Int, Int>>): Triple<Int, Int, Int>? {

    var closestPoint: Triple<Int, Int, Int>? = null
    var minDistance = Double.POSITIVE_INFINITY

    for (point in points) {
        if (point == null) {
            continue
        }

        // Calculate the distance from the origin (0, 0, 0)
        val distance = Math.sqrt((point.first * point.first + point.second * point.second + point.third * point.third).toDouble())

        if (distance != 0.0 && distance < minDistance) {
            minDistance = distance
            closestPoint = point
        }
    }

    return closestPoint
}