Practice
Sports League Match Tracker
2023/Feb/Mar·Variant 2
HARDAlgorithms
A sports team earns points based on match results: 3 for an away win, 2 for a home win, 1 for a drawn match, and 0 for a lost match.
Write a program that first reads the total number of matches played (MatchNo). Then, it should loop MatchNo times, reading the result of each match (3, 2, 1, or 0). Calculate the total points for the team and count the number of away wins, home wins, draws, and losses.
Input: An integer representing MatchNo, followed by MatchNo integers representing the match results.
Output: 5 lines displaying the total points and the counts for each result type.
Example:
Input: 4
3
2
1
0
Output: Total points: 6
Away wins: 1
Home wins: 1
Draws: 1
Losses: 1
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: One of each result
Inputs: 4, 3, 2, 1, 0
Expected: Total points: 6
Away wins: 1
Home wins: 1
Draws: 1
Losses: 1
Test 2: All away wins
Inputs: 5, 3, 3, 3, 3, 3
Expected: Total points: 15
Away wins: 5
Home wins: 0
Draws: 0
Losses: 0
Ctrl+Enter
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade