Count league points
A sports league awards 3 points for a win and 1 for a draw. Total the points earned.
- A win is worth 3 points.
- A draw is worth 1 point.
- Losses earn nothing.
LeaguePoints(wins: int, draws: int) → int
C# needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.
Where you start
public int LeaguePoints(int wins, int draws) {
}
Worked examples
| Call | Result |
|---|---|
LeaguePoints(3, 1) | 10 |
LeaguePoints(0, 0) | 0 |
LeaguePoints(1, 1) | 4 |
LeaguePoints(5, 0) | 15 |
Hint
Multiply wins by three and add the draws.
Reference solution in C#
public int LeaguePoints(int wins, int draws) {
return 3 * wins + draws;
}