/**
 * Given a map of observations made by an astronomer, calculate the average distance of all observed celestial objects.
 *
 * @param observations A map containing the name of celestial objects as keys and their distances in light-years as values.
 * @return The average distance of all observed celestial objects.
 *
 * Example:
 * observations = mapOf(
 *     "Andromeda Galaxy" to 2.537,
 *     "Whirlpool Galaxy" to 37.0,
 *     "Triangulum Galaxy" to null,
 *     "Orion Nebula" to 1.344,
 *     "Pleiades Star Cluster" to null
 * )
 * calculateAverageDistance(observations) // 13.96
 */
fun calculateAverageDistance(observations: Map<String, Double?>): Double {

    val distances = observations.values.filterNotNull()
    val totalDistances = distances.sum()
    return if (distances.isNotEmpty()) totalDistances / distances.size else 0.0
}
/**
 * Given a map of observations made by an astronomer, calculate the average distance of all observed celestial objects.
 *
 * @param observations A map containing the name of celestial objects as keys and their distances in light-years as values.
 * @return The average distance of all observed celestial objects.
 *
 * Example:
 * observations = mapOf(
 *     "Andromeda Galaxy" to 2.537,
 *     "Whirlpool Galaxy" to 37.0,
 *     "Triangulum Galaxy" to null,
 *     "Orion Nebula" to 1.344,
 *     "Pleiades Star Cluster" to null
 * )
 * calculateAverageDistance(observations) // 13.96
 */
fun calculateAverageDistance(observations: Map<String, Double?>): Double {
/**
 * Given a map of observations made by an astronomer, calculate the average distance of all observed celestial objects.
 *
 * @param observations A map containing the name of celestial objects as keys and their distances in light-years as values.
 * @return The average distance of all observed celestial objects.
 *
 * Example:
 * observations = mapOf(
 *     "Andromeda Galaxy" to 2.537,
 *     "Whirlpool Galaxy" to 37.0,
 *     "Triangulum Galaxy" to null,
 *     "Orion Nebula" to 1.344,
 *     "Pleiades Star Cluster" to null
 * )
 * calculateAverageDistance(observations) // 13.96
 */
fun calculateAverageDistance(observations: Map<String, Double?>): Double {

    val distances = observations.values.filterNotNull()
    val totalDistances = distances.sum()
    return if (distances.isNotEmpty()) totalDistances / distances.size else 0.0
}