Practice
League Points from a Results Grid
2024/May/June·Variant 3·Q9·[10 marks]
MEDIUM2D Arrays
A 1D array Teams[1:3] stores team names. A 2D array Results[1:3, 1:3] stores, for each team, games won (column 1), drawn (column 2) and lost (column 3).
Points: 3 for a win, 1 for a draw, 0 for a loss. Read the three names and nine result counts. Output each team's name and points, then the name of the team with the highest points (the earlier team wins a tie).
Inspired by Cambridge IGCSE (0478) May/June 2024 Paper 23 Question 9, reduced to 3 teams.
Input: 3 names, then 9 integers (won, drawn, lost for each team).
Output: Three <name> <points> lines, then Winner: <name>.
Example:
Input: Lions
Tigers
Bears
2
1
0
1
1
1
0
2
1
Output: Lions 7
Tigers 4
Bears 2
Winner: Lions
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Clear winner
Inputs: Lions, Tigers, Bears, 2, 1, 0, 1, 1, 1, 0, 2, 1
Expected: Lions 7
Tigers 4
Bears 2
Winner: Lions
Test 2: All lost; first team wins the tie
Inputs: Red, Blue, Green, 0, 0, 3, 0, 0, 3, 0, 0, 3
Expected: Red 0
Blue 0
Green 0
Winner: Red