Mr. Rigby is a huge fan of football.
His favourite competition is the North West England Semi-Professional Invitational League, but he has forgotten all of the results from last year!
Luckily, he has been able to find a text file online that lists the all of the final scores for each team in: football-league.txt
.
For example, the first row of the text file shows:
Adlington Town,5–1,1–1,3–1,2–1,2–0,2–3, ...
This means the first 6 results for Adlington Town were:
- Win 5-1
- Draw 1-1
- Win 3-1
- Win 2-1
- Win 2-0
- Lose 2-3
In football, points are awarded as follows:
- Win = 3 points
- Draw = 1 point
- Loss = 0 points
Using the data in the text file, calculate and output the total number of points each team scored by the end of the season.
Then output the name of the team who won the competition.
The bonus points for this task are awarded if you can list all teams in descending order by their total number of points.
For example, your final output might look like...
Team A were the champions.
League table:
1 - Team A - 80 points
2 - Team B - 77 points
3 - Team C - 76 points
4 -
etc...