refactor: pairing algorithm #1

Merged
catalin merged 1 commit from pairing into main 2023-12-13 16:28:12 +00:00
Showing only changes of commit fcd9650701 - Show all commits

refactor: pairing algorithm

DvRodri8 2023-12-13 17:26:18 +01:00
Signed by: DVRodri8
GPG key ID: 803626926BE41D50

View file

@ -15,20 +15,10 @@ class Group(BaseModel):
@staticmethod
def pair(names: list[str]) -> dict[str, str]:
names_copy = names[:]
random.shuffle(names_copy)
pairings = {}
for i, name in enumerate(names):
pair = names_copy[i]
while pair == name:
random.shuffle(names_copy)
pair = names_copy[i]
pairings[name] = pair
return pairings
random.shuffle(names)
names_copy = names[1:]
names_copy.append(names[0])
return dict(zip(names, names_copy))
class IRepo(ABC):
@abstractmethod