kyu_5.sports_league_table_ranking package
Submodules
kyu_5.sports_league_table_ranking.compute_ranks module
Solution for -> Sports League Table Ranking.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- kyu_5.sports_league_table_ranking.compute_ranks.calc_for_against(teams, team, team_1, team_2) None[source]
Collect “For:Against” data.
- Parameters:
teams
team
team_1
team_2
- Returns:
- kyu_5.sports_league_table_ranking.compute_ranks.calc_gd(teams) None[source]
Calculate “GD”.
- Parameters:
teams
- Returns:
- kyu_5.sports_league_table_ranking.compute_ranks.calc_rank(teams: dict) None[source]
Calculate Rank.
First you sort the teams by their points. If two or more teams reached the same number of points, the second criteria comes into play and so on. Finally, if all criteria are the same, the teams share a place. :param teams: :return:
- kyu_5.sports_league_table_ranking.compute_ranks.calc_team_points(team, teams, score_a, score_b) None[source]
Calculate team points.
- Parameters:
team
teams
score_a
score_b
- Returns:
- kyu_5.sports_league_table_ranking.compute_ranks.calc_teams_score(team_a, team_b, teams, team, number) None[source]
Calculate following For/Against Points.
Set default values for team as well. :param team_a: :param team_b: :param teams: :param team: :param number: :return:
- kyu_5.sports_league_table_ranking.compute_ranks.check_if_team_registered(team, teams, number) None[source]
Check if team data was processed.
Set default values otherwise. :param team: :param teams: :param number: :return:
- kyu_5.sports_league_table_ranking.compute_ranks.compute_ranks(number: int, games: list) list[source]
compute_ranks function.
Organize a sports league in a round-robin-system. Each team meets all other teams. In your league a win gives a team 2 points, a draw gives both teams 1 point. After some games you have to compute the order of the teams in your league. You use the following criteria to arrange the teams:
Points Scoring differential (the difference between goals scored and those conceded)
Goals scored First you sort the teams by their points. If two or more teams reached the same number of points, the second criteria comes into play and so on. Finally, if all criteria are the same, the teams share a place.
- Parameters:
number – int
games – list
- Returns:
list
kyu_5.sports_league_table_ranking.test_compute_ranks module
Test for -> Sports League Table Ranking.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- class kyu_5.sports_league_table_ranking.test_compute_ranks.ComputeRanksTestCase(methodName='runTest')[source]
Bases:
TestCaseTesting Sports League Table Ranking.
- _classSetupFailed = False
- _class_cleanups = []
- test_compute_ranks = None
- test_compute_ranks_0(**kw)
Testing compute_ranks function [with number=6, games=[[0, 5, 2, 2], [1, 4, 0, 2], [2,… 2], [3, 1, 1, 1], [4, 0, 2, 0]], expected=[4, 4, 6, 3, 1, 2]].
Test the compute_ranks function that organizes a sports league in a round-robin-system. Each team meets all other teams. In your league a win gives a team 2 points, a draw gives both teams 1 point. After some games you have to compute the order of the teams in your league. You use the following criteria to arrange the teams: 1. Points. 2. Scoring differential (the difference between goals scored and those conceded). 3. Goals scored. :return:
- test_compute_ranks_1(**kw)
Testing compute_ranks function [with number=6, games=[[0, 5, 2, 0], [1, 4, 2, 2], [2,… 0], [2, 0, 2, 1], [3, 4, 3, 1]], expected=[2, 3, 4, 1, 5, 6]].
Test the compute_ranks function that organizes a sports league in a round-robin-system. Each team meets all other teams. In your league a win gives a team 2 points, a draw gives both teams 1 point. After some games you have to compute the order of the teams in your league. You use the following criteria to arrange the teams: 1. Points. 2. Scoring differential (the difference between goals scored and those conceded). 3. Goals scored. :return:
- test_compute_ranks_2(**kw)
Testing compute_ranks function [with number=4, games=[[0, 3, 1, 1], [1, 2, 2, 2], [1, 3, 2, 0], [2, 0, 2, 0]], expected=[3, 1, 1, 3]].
Test the compute_ranks function that organizes a sports league in a round-robin-system. Each team meets all other teams. In your league a win gives a team 2 points, a draw gives both teams 1 point. After some games you have to compute the order of the teams in your league. You use the following criteria to arrange the teams: 1. Points. 2. Scoring differential (the difference between goals scored and those conceded). 3. Goals scored. :return:
- test_compute_ranks_3(**kw)
Testing compute_ranks function [with number=10, games=[], expected=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]].
Test the compute_ranks function that organizes a sports league in a round-robin-system. Each team meets all other teams. In your league a win gives a team 2 points, a draw gives both teams 1 point. After some games you have to compute the order of the teams in your league. You use the following criteria to arrange the teams: 1. Points. 2. Scoring differential (the difference between goals scored and those conceded). 3. Goals scored. :return:
- test_compute_ranks_4(**kw)
Testing compute_ranks function [with number=8, games=[[0, 7, 2, 0]], expected=[1, 2, 2, 2, 2, 2, 2, 8]].
Test the compute_ranks function that organizes a sports league in a round-robin-system. Each team meets all other teams. In your league a win gives a team 2 points, a draw gives both teams 1 point. After some games you have to compute the order of the teams in your league. You use the following criteria to arrange the teams: 1. Points. 2. Scoring differential (the difference between goals scored and those conceded). 3. Goals scored. :return:
Module contents
Sports League Table Ranking.