/**
 * This function aims to return the names of all planets that an astronomer has discovered.
 *
 * @param planets a list of planets discovered by the astronomer
 * @return a list of planet names
 */
fun getPlanetNames(planets: List<Map<String, Any>?>): List<String> {

    val planetNames = mutableListOf<String>()
    for (planet in planets) {
        if (planet != null && planet["name"] != "") {
            planetNames.add(planet["name"] as String)
        }
    }
    return planetNames
}

// Example usage:
val astronomerPlanets = listOf(
    mapOf("name" to "Mercury", "distance" to 0.39),
    mapOf("name" to "Venus", "distance" to 0.72),
    null,
    mapOf("name" to "Mars", "distance" to 1.52),
    mapOf("name" to "", "distance" to 5.20),
    mapOf("name" to "Jupiter", "distance" to 5.20),
    mapOf("name" to "Saturn", "distance" to 9.58),
    null,
    mapOf("name" to "Uranus", "distance" to 19.18),
    mapOf("name" to "Neptune", "distance" to 30.07)
)

val planetNames = getPlanetNames(astronomerPlanets)
/**
 * This function aims to return the names of all planets that an astronomer has discovered.
 *
 * @param planets a list of planets discovered by the astronomer
 * @return a list of planet names
 */
fun getPlanetNames(planets: List<Map<String, Any>?>): List<String> {
/**
 * This function aims to return the names of all planets that an astronomer has discovered.
 *
 * @param planets a list of planets discovered by the astronomer
 * @return a list of planet names
 */
fun getPlanetNames(planets: List<Map<String, Any>?>): List<String> {

    val planetNames = mutableListOf<String>()
    for (planet in planets) {
        if (planet != null && planet["name"] != "") {
            planetNames.add(planet["name"] as String)
        }
    }
    return planetNames
}

// Example usage:
val astronomerPlanets = listOf(
    mapOf("name" to "Mercury", "distance" to 0.39),
    mapOf("name" to "Venus", "distance" to 0.72),
    null,
    mapOf("name" to "Mars", "distance" to 1.52),
    mapOf("name" to "", "distance" to 5.20),
    mapOf("name" to "Jupiter", "distance" to 5.20),
    mapOf("name" to "Saturn", "distance" to 9.58),
    null,
    mapOf("name" to "Uranus", "distance" to 19.18),
    mapOf("name" to "Neptune", "distance" to 30.07)
)

val planetNames = getPlanetNames(astronomerPlanets)