问题描述
我们有 16 个团队和 2 个场地。周一 60 分钟和周二 120 分钟均可使用 2 个场地。这意味着周一可以进行 2 场比赛,周二可以进行 4 场比赛。如果一支球队不能在同一天再次参加比赛,那么周一和周二可以分别进行多少场比赛。
提示:-
- N 支球队的比赛次数, = (N-1)+(N-2)+(N-3)+(N-4).....+(N-N) 16支球队的例子 (16-1)+(16-2)+(16-3)....+(16-16)= 120 匹配
我们如何找到N个团队和N个场地的公式? 我在询问最佳解决方案,以便我可以找到最短天数来完成所有比赛。
解决方法
from itertools import combinations
# Get all combinations of 16 teams and length 2
# Formula for combination is Nc2 = ((N)*(N-1))/2)
total_no_match = combinations([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],2)
total_no_match = list(total_no_match)
total_no_match = [str(total_no_match) for total_no_match in total_no_match]
print("Total number of matches:",len(total_no_match))
# On Monday 2 Matches and on Tuesday 4 Matches can be played. So total no of matches played in a week = 6
m = 2
t = 4
# Total no weeks required to complete 120 match:
total_week = (len(total_no_match))/(m+t)
total_week = int(total_week)
print("Total week required to complete {} match:".format(len(total_no_match)),total_week)
# No of matches on Monday:
total_match_on_monday = total_week*m
print("Total number of Match on Monday:",total_match_on_monday)
# No of matches on Monday:
total_match_on_tuesday = total_week*t
print("Total number of Match on Tuesday:",total_match_on_tuesday)
输出:
匹配总数:120
完成 120 场比赛所需的总周数:20
周一比赛总数:40
周二比赛总数:80
,我们可以简单地使用 N×(N-1)/2(罗宾回合锦标赛)的公式来计算比赛总数,在这种情况下,我们的答案是 120。
如前所述,一周内可能有 6 场比赛,因此 120 场比赛需要 20 场。
周一 2 次,周二 4 次,表示周一 40 次,其余 80 次在周二,持续 20 周。