/**
 * A farmer wants to calculate the total value of a specific subset of his animals based on their prices.
 *
 * @param farmAnimals A set containing the names of all the animals on the farm.
 * @param prices A map where the keys represent the animal names and the values represent their prices.
 * @return The total value of the selected animals.
 */
fun farmerExercise(farmAnimals: Set<String>, prices: Map<String, Float>): Float {

    // Select only the animals that have prices assigned
    val animalsWithPrices = farmAnimals.filter { it in prices }.sorted()

    // Calculate the total value of the selected animals
    val totalValue = animalsWithPrices.sumByDouble { prices[it]!!.toDouble() }.toFloat()

    return totalValue
}
/**
 * A farmer wants to calculate the total value of a specific subset of his animals based on their prices.
 *
 * @param farmAnimals A set containing the names of all the animals on the farm.
 * @param prices A map where the keys represent the animal names and the values represent their prices.
 * @return The total value of the selected animals.
 */
fun farmerExercise(farmAnimals: Set<String>, prices: Map<String, Float>): Float {
/**
 * A farmer wants to calculate the total value of a specific subset of his animals based on their prices.
 *
 * @param farmAnimals A set containing the names of all the animals on the farm.
 * @param prices A map where the keys represent the animal names and the values represent their prices.
 * @return The total value of the selected animals.
 */
fun farmerExercise(farmAnimals: Set<String>, prices: Map<String, Float>): Float {

    // Select only the animals that have prices assigned
    val animalsWithPrices = farmAnimals.filter { it in prices }.sorted()

    // Calculate the total value of the selected animals
    val totalValue = animalsWithPrices.sumByDouble { prices[it]!!.toDouble() }.toFloat()

    return totalValue
}