half = count / 2
for turn in range(sets):
    left = units[:half]
right = units[count - half - 1 + 1:][::-1]
pairings = zip(left, right)
if turn % 2 == 1:
    pairings = [(y, x) for x, y in pairings]
units.insert(1, units.pop())
yield pairings
teams = ['a', 'b', 'c', 'd']
print(list(round_robin(teams, sets=len(teams) * 2 - 2)))
Генерация естественного расписания для спортивной лиги