import math
from itertools import permutations
def make_bo(n):
need_win = math.ceil(n / 2)
if n % 2 == 0:
need_win += 1
change_score = need_win - 1
all_score = [(n // 2, n // 2)]
else:
change_score = need_win
all_score = []
battles = [[need_win, i] for i in range(change_score)]
for battle in battles:
for score in permutations(battle, 2):
all_score.append(score)
return all_score
# bo2 两局两胜
print(make_bo(2)) # [(1, 1), (2, 0), (0, 2)]
# bo4 四局三胜
print(make_bo(4)) # [(2, 2), (3, 0), (0, 3), (3, 1), (1, 3)]
# bo1 一局一胜
print(make_bo(1)) # [(1, 0), (0, 1)]
# bo3 三局两胜
print(make_bo(3)) # [(2, 0), (0, 2), (2, 1), (1, 2)]
# bo5 五局三胜
print(make_bo(5)) # [(3, 0), (0, 3), (3, 1), (1, 3), (3, 2), (2, 3)]
# bo7 七局四胜
print(make_bo(7)) # [(4, 0), (0, 4), (4, 1), (1, 4), (4, 2), (2, 4), (4, 3), (3, 4)]
回合制生成比分
于 2022-09-16 17:51:29 首次发布