Skip to the content

What you need on the last exam

Problem

The class has three exams, all worth the same. You've taken two of them and your average on those two is what you have so far; you want to finish the class with goal as your final average. Return the score you need on the third one: with an average of 80 and a goal of 85, you need 95. The answer can go over 100 (you can't get there anymore) or come out negative (you already have it). Return it as is either way, don't clip it.

Examples

  • 80, 85 → 95

  • Holding the average

    90, 90 → 90

  • Plenty of room

    95, 80 → 50

  • Half a point of average

    77.5, 80 → 85

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

You start with this

Python

def score_needed(average, goal):
    pass

JavaScript

function scoreNeeded(average, goal) {
}
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 →