Skip to content

Instantly share code, notes, and snippets.

@e4c5
e4c5 / round_robin.py
Last active February 9, 2024 08:05
A round robing pairing generator where you are control the round in which certain players get the bye or meet certain other players. If a large number of rounds need to be fixed in this manner and they involve players other than the Bye, there is no guarantee that a pairing exists.
import sys
import random
from itertools import permutations
class RoundRobin(object):
'''
Usage:
r = RoundRobin(['Bye','Nigel','Wellignton','Andrew','Sherwin','Chollapat','David','Craig'])
r.fix_pairing('Nigel',5, 'Bye')
r.fix_pairing( 'Craig',0,'Bye')