/**
 * This function calculates the overall score for a given athlete based on their score and rank.
 * It applies a weighted calculation based on their rank, giving higher importance to lower ranks.
 *
 * @param athleteScore The raw score obtained by the athlete.
 * @param athleteRank The rank of the athlete in the competition.
 * @return The overall score of the athlete after applying the weighted calculation.
 */
fun calculateScore(athleteScore: Int, athleteRank: Int): Float? {

    if (athleteRank < 0 || athleteScore < 0) {
        return null
    }

    return when (athleteRank) {
        in 1..3 -> athleteScore * 0.9f
        in 4..10 -> athleteScore * 0.8f
        in 11..20 -> athleteScore * 0.7f
        in 21..50 -> athleteScore * 0.6f
        in 51..100 -> athleteScore * 0.5f
        else -> null
    }
}
/**
 * This function calculates the overall score for a given athlete based on their score and rank.
 * It applies a weighted calculation based on their rank, giving higher importance to lower ranks.
 *
 * @param athleteScore The raw score obtained by the athlete.
 * @param athleteRank The rank of the athlete in the competition.
 * @return The overall score of the athlete after applying the weighted calculation.
 */
fun calculateScore(athleteScore: Int, athleteRank: Int): Float? {
/**
 * This function calculates the overall score for a given athlete based on their score and rank.
 * It applies a weighted calculation based on their rank, giving higher importance to lower ranks.
 *
 * @param athleteScore The raw score obtained by the athlete.
 * @param athleteRank The rank of the athlete in the competition.
 * @return The overall score of the athlete after applying the weighted calculation.
 */
fun calculateScore(athleteScore: Int, athleteRank: Int): Float? {

    if (athleteRank < 0 || athleteScore < 0) {
        return null
    }

    return when (athleteRank) {
        in 1..3 -> athleteScore * 0.9f
        in 4..10 -> athleteScore * 0.8f
        in 11..20 -> athleteScore * 0.7f
        in 21..50 -> athleteScore * 0.6f
        in 51..100 -> athleteScore * 0.5f
        else -> null
    }
}