/**
 * Given a nested list of stars, the function finds the brightest star and returns its coordinates.
 * Each star's coordinates are represented as a Pair of (x, y) where x represents the horizontal position
 * and y represents the vertical position.
 *
 * @param stars A nested list of stars where each sub-list consists of star coordinates.
 * @return The coordinates (x, y) of the brightest star in the given list of stars.
 */
fun findBrightestStar(stars: List<List<Star>>): Pair<Int, Int> {

    var brightestMagnitude: Int? = null
    var brightestCoordinates: Pair<Int, Int>? = null

    for (x in stars.indices) {
        for (y in stars[x].indices) {
            val magnitude = stars[x][y].magnitude  // Magnitude of the star

            if (brightestMagnitude == null || magnitude < brightestMagnitude!!) {
                brightestMagnitude = magnitude
                brightestCoordinates = Pair(x, y)
            }
        }
    }

    return brightestCoordinates!!
}

val stars = listOf(
    listOf(Star(0, 0, 5), Star(0, 1, 2), Star(1, 0, 3), Star(1, 1, 7)),
    listOf(Star(2, 0, 4), Star(2, 1, 6), Star(3, 0, 1), Star(3, 1, 8))
)

data class Star(val x: Int, val y: Int, val magnitude: Int)
/**
 * Given a nested list of stars, the function finds the brightest star and returns its coordinates.
 * Each star's coordinates are represented as a Pair of (x, y) where x represents the horizontal position
 * and y represents the vertical position.
 *
 * @param stars A nested list of stars where each sub-list consists of star coordinates.
 * @return The coordinates (x, y) of the brightest star in the given list of stars.
 */
fun findBrightestStar(stars: List<List<Star>>): Pair<Int, Int> {
/**
 * Given a nested list of stars, the function finds the brightest star and returns its coordinates.
 * Each star's coordinates are represented as a Pair of (x, y) where x represents the horizontal position
 * and y represents the vertical position.
 *
 * @param stars A nested list of stars where each sub-list consists of star coordinates.
 * @return The coordinates (x, y) of the brightest star in the given list of stars.
 */
fun findBrightestStar(stars: List<List<Star>>): Pair<Int, Int> {

    var brightestMagnitude: Int? = null
    var brightestCoordinates: Pair<Int, Int>? = null

    for (x in stars.indices) {
        for (y in stars[x].indices) {
            val magnitude = stars[x][y].magnitude  // Magnitude of the star

            if (brightestMagnitude == null || magnitude < brightestMagnitude!!) {
                brightestMagnitude = magnitude
                brightestCoordinates = Pair(x, y)
            }
        }
    }

    return brightestCoordinates!!
}

val stars = listOf(
    listOf(Star(0, 0, 5), Star(0, 1, 2), Star(1, 0, 3), Star(1, 1, 7)),
    listOf(Star(2, 0, 4), Star(2, 1, 6), Star(3, 0, 1), Star(3, 1, 8))
)

data class Star(val x: Int, val y: Int, val magnitude: Int)