/**
 * Given a dictionary of star distances and the name of a star, 
 * return the distance of the star from Earth.
 * 
 * @param starDistances A dictionary where keys are star names and values are their distances in light-years.
 * @param starName The name of the star for which distance needs to be fetched.
 * @return The distance of the star from Earth if found, null otherwise.
 * @throws IllegalArgumentException If the distance value is not a valid floating-point number.
 */
fun getStarDistance(starDistances: Map<String, Double>, starName: String): Double? {

    val epsilon = 1e-8  // An infinitesimally small value
    
    if (starName in starDistances) {
        val distance = starDistances[starName]
        
        if (distance is Double) {
            if (distance < epsilon) {
                throw IllegalArgumentException("Invalid distance value: 0.0 or negative distance.")
            } else {
                return distance
            }
        } else {
            try {
                distance?.toDouble()
            } catch (e: NumberFormatException) {
                throw IllegalArgumentException("Invalid distance value: Not a valid floating-point number.")
            }
        }
    }
    
    return null
}
/**
 * Given a dictionary of star distances and the name of a star, 
 * return the distance of the star from Earth.
 * 
 * @param starDistances A dictionary where keys are star names and values are their distances in light-years.
 * @param starName The name of the star for which distance needs to be fetched.
 * @return The distance of the star from Earth if found, null otherwise.
 * @throws IllegalArgumentException If the distance value is not a valid floating-point number.
 */
fun getStarDistance(starDistances: Map<String, Double>, starName: String): Double? {
/**
 * Given a dictionary of star distances and the name of a star, 
 * return the distance of the star from Earth.
 * 
 * @param starDistances A dictionary where keys are star names and values are their distances in light-years.
 * @param starName The name of the star for which distance needs to be fetched.
 * @return The distance of the star from Earth if found, null otherwise.
 * @throws IllegalArgumentException If the distance value is not a valid floating-point number.
 */
fun getStarDistance(starDistances: Map<String, Double>, starName: String): Double? {

    val epsilon = 1e-8  // An infinitesimally small value
    
    if (starName in starDistances) {
        val distance = starDistances[starName]
        
        if (distance is Double) {
            if (distance < epsilon) {
                throw IllegalArgumentException("Invalid distance value: 0.0 or negative distance.")
            } else {
                return distance
            }
        } else {
            try {
                distance?.toDouble()
            } catch (e: NumberFormatException) {
                throw IllegalArgumentException("Invalid distance value: Not a valid floating-point number.")
            }
        }
    }
    
    return null
}