Skip to the content

The average without the worst

Problem

Three grades arrive in a list and the teacher forgives the lowest one: the average is taken from the other two.

With [6, 10, 8] the 6 is dropped and you return 9.0, the average of 10 and 8.

If the bottom is a tie, like in [7, 7, 9], only one grade is forgiven and the average is 8.0.

Three grades always arrive, they are always whole numbers, and the result can end in half a point.

Examples

  • The lowest comes first

    [6, 10, 8] → 9

  • The lowest in the middle

    [5, 4, 9] → 7

  • Half a point

    [8, 9, 6] → 8.5

Besides these, the challenge has hidden tests that are revealed when you submit your solution.

You start with this

Python

def best_average(grades):
    pass

JavaScript

function bestAverage(grades) {
}
Solve this challenge

It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.

More O(1) challenges

See all challenges →