Question: In this exercise we develop an algorithm to sort the result table of the Super 18 rugby competition. Input is a file with comma separated
In this exercise we develop an algorithm to sort the result table of the Super 18 rugby competition. Input is a file with comma separated values. Each line of the file contains the name of a team, the conference the team is assigned to, number of points of the team and the goals for and against the team. The goal difference is computed as goals for a team minus goals against the team.
Please write a program ResultTable.py, which reads such a file and (a) outputs all teams in sorted order and (b) outputs the teams for each conference in sorted order.
The sorting order is defined as follows: higher points means a higher rank, if the points are equal then a higher goal difference corresponds to a higher rank. If the points and goal difference are equal then a higher number of goals for the team corresponds to a higher rank. If two teams have exactly the same number of points, goal difference, and goals for the team, then the order of these two teams is undefined (i.e. either could be in front).
Your program should display the rank, team name, conference, points, goal difference, and for and against goals separated by a :. The output should be neatly formatted as shown above.
Example:

Text for Input:
Blues, 4, 40, 374, 380 Brumbies, 3, 43, 425, 326 Bulls, 1, 47, 420, 260 Cheetahs, 1, 22, 372, 487 Chiefs, 4, 51, 491, 341 Crusaders, 4, 50, 487, 317 Force, 3, 13, 260, 441 Highlanders, 4, 52, 430, 286 Hurricanes, 4, 52, 458, 314 Jaguars, 2, 22, 418, 476 Lions, 2, 52, 535, 349 Rebels, 3, 31, 365, 486 Reds, 3, 17, 290, 458 Sharks, 2, 47, 418, 231 Southern Kings, 2, 9, 282, 684 Stormers, 1, 47, 425, 265 Sunwolves, 1, 9, 293, 627 Waratahs, 3, 40, 413, 317
Process started >> Team Conference points Diff Goals 52 186 535:349 1. Lions 2. Hurricanes 52 144 458: 314 52 144 430:286 51 150 491:341 50 170 487:317 3. Highlanders Chiefs 5. Crusaders Sharks 7. Stormers Bulls 47 187 418:231 47 160 425:265 47 160 420:260 43 99 425:326 9. Brumbies 10. Waratahs 40 96 413:317 40 374:380 11. Blues 12 Rebels 31 121 365:486 22 58 418:476 13. Jaguars 14 . Cheetahs 22 115 372:487 Reds 17 168 290:458 16 Force 17. Sunwolves 18. Southern Kings 13 181 260:441 334 293: 627 402 282: 694 Conference 1 Team Conference points DILL Goals 47 160 425:265 Stormers 2. Bulls 3. Cheetahs 47 160 115 420:260 372: 407 tablel bet - Notepad 4. Sunwolves 334 293: 627 File Edit Format View Help Conference 2 Team Conference Points Diff Goals 1. Lions 2. Sharks 52 186 535:349 47 187 418:231 3. Jaguars 4. Southern Kings 22 -58 402 418:476 282: 684 Conference 3 Team 1. Brumbies Conference Points Diff Goals 43 99 425: 326 Blues, 4, 40, 374, 380 Brumbies, 3, 43, 425, 326 Bulls, 1, 47, 420, 260 Cheetahs, 1, 22, 372, 487 Chiefs, 4, 51, 491, 341 Crusaders, 4, 50, 487, 317 Force, 3, 13, 260, 441 Highlanders, 4, 52, 430, 286 Hurricanes, 4, 52, 458, 314 Jaguars, 2, 22, 418, 476 Lions, 2, 52, 535, 349 Rebels, 3, 31, 365, 486 Reds, 3, 17, 290, 458 Sharks, 2, 47, 418, 231 Southern Kings, 2, 9, 282, 684 Stormers, 1, 47, 425, 265 Sunwolves, 1, 9, 293, 627 Waratahs, 3, 40, 413, 317 2. Waratahs Rebels 40 96 413:317 31 121 365:486 17 168 290:458 Reds 5. Force 13 181 260:441 Conference Team Conference Points Diff Goals 1. Hurricanes 52 144 458:314 2. Highlanders 52 144 430:286 Chiefs 51 150 491:341 4. Crusaders 50 170 487:317 Blues 40 374:380
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
