/**
 * Astronomer code to count the number of planets in a solar system
 */
fun countNumberOfPlanets(): Int {

    var numOfPlanets = 0  // Initialize the counter for planets

    // Nested loop to iterate over all the solar systems
    for (solarSystem in astronomerData) {
        val numOfStars = solarSystem["number_of_stars"] as Int

        // Nested loop to iterate over all the stars in each solar system
        for (star in solarSystem["stars"] as List<Map<String, Any>>) {
            numOfPlanets += star["number_of_planets"] as Int

            // Nested logical operator to check conditions for planets
            if (numOfStars > 1 && star["habitable_zone"] == true && star["age"] as Double > 5e9 && star["mass"] as Double > 1.5) {
                numOfPlanets++
            }
        }
    }

    return numOfPlanets
}

// Astronomer data format
val astronomerData = listOf(
    mapOf(
        "number_of_stars" to 1,
        "stars" to listOf(
            mapOf(
                "number_of_planets" to 5,
                "habitable_zone" to true,
                "age" to 4e9,
                "mass" to 1.2
            )
        )
    )
)
/**
 * Astronomer code to count the number of planets in a solar system
 */
fun countNumberOfPlanets(): Int {
/**
 * Astronomer code to count the number of planets in a solar system
 */
fun countNumberOfPlanets(): Int {

    var numOfPlanets = 0  // Initialize the counter for planets

    // Nested loop to iterate over all the solar systems
    for (solarSystem in astronomerData) {
        val numOfStars = solarSystem["number_of_stars"] as Int

        // Nested loop to iterate over all the stars in each solar system
        for (star in solarSystem["stars"] as List<Map<String, Any>>) {
            numOfPlanets += star["number_of_planets"] as Int

            // Nested logical operator to check conditions for planets
            if (numOfStars > 1 && star["habitable_zone"] == true && star["age"] as Double > 5e9 && star["mass"] as Double > 1.5) {
                numOfPlanets++
            }
        }
    }

    return numOfPlanets
}

// Astronomer data format
val astronomerData = listOf(
    mapOf(
        "number_of_stars" to 1,
        "stars" to listOf(
            mapOf(
                "number_of_planets" to 5,
                "habitable_zone" to true,
                "age" to 4e9,
                "mass" to 1.2
            )
        )
    )
)