/**
 * This exercise focuses on adding elements to a set and using the division assignment operator to manipulate the set.
 *
 * Given an athlete and a list of elements, add each element to the athlete's set 'achievements' and then divide each element in the set by the athlete's total score.
 *
 * @param athlete A map representing the athlete with the following keys:
 *      'name' (String): The name of the athlete.
 *      'total_score' (Double): The total score of the athlete.
 *      'achievements' (MutableSet<Double>): A set of achievements.
 * @param elements A list of elements to be added to the athlete's set.
 * @return The updated athlete map with the added elements in 'achievements' set and the division assignment operation applied to each element.
 */
fun addDivideSet(athlete: MutableMap<String, Any>, elements: List<Double>): MutableMap<String, Any> {

    // Adding elements to the athlete's set 'achievements'
    athlete["achievements"] = (athlete["achievements"] as MutableSet<Double>).apply { addAll(elements) }

    // Dividing each element in the set by the athlete's total score
    (athlete["achievements"] as MutableSet<Double>).forEach { element ->
        (athlete["achievements"] as MutableSet<Double>).remove(element)
        (athlete["achievements"] as MutableSet<Double>).add(element / (athlete["total_score"] as Double))
    }

    return athlete
}
/**
 * This exercise focuses on adding elements to a set and using the division assignment operator to manipulate the set.
 *
 * Given an athlete and a list of elements, add each element to the athlete's set 'achievements' and then divide each element in the set by the athlete's total score.
 *
 * @param athlete A map representing the athlete with the following keys:
 *      'name' (String): The name of the athlete.
 *      'total_score' (Double): The total score of the athlete.
 *      'achievements' (MutableSet<Double>): A set of achievements.
 * @param elements A list of elements to be added to the athlete's set.
 * @return The updated athlete map with the added elements in 'achievements' set and the division assignment operation applied to each element.
 */
fun addDivideSet(athlete: MutableMap<String, Any>, elements: List<Double>): MutableMap<String, Any> {
/**
 * This exercise focuses on adding elements to a set and using the division assignment operator to manipulate the set.
 *
 * Given an athlete and a list of elements, add each element to the athlete's set 'achievements' and then divide each element in the set by the athlete's total score.
 *
 * @param athlete A map representing the athlete with the following keys:
 *      'name' (String): The name of the athlete.
 *      'total_score' (Double): The total score of the athlete.
 *      'achievements' (MutableSet<Double>): A set of achievements.
 * @param elements A list of elements to be added to the athlete's set.
 * @return The updated athlete map with the added elements in 'achievements' set and the division assignment operation applied to each element.
 */
fun addDivideSet(athlete: MutableMap<String, Any>, elements: List<Double>): MutableMap<String, Any> {

    // Adding elements to the athlete's set 'achievements'
    athlete["achievements"] = (athlete["achievements"] as MutableSet<Double>).apply { addAll(elements) }

    // Dividing each element in the set by the athlete's total score
    (athlete["achievements"] as MutableSet<Double>).forEach { element ->
        (athlete["achievements"] as MutableSet<Double>).remove(element)
        (athlete["achievements"] as MutableSet<Double>).add(element / (athlete["total_score"] as Double))
    }

    return athlete
}