-
-
Save aigarius/2c99ede12539ca536849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
people = ['Aigars', 'Baiba', 'Centis', 'Daira', 'Edgars', 'Fins', 'Gita', 'Helmuts'] | |
banned = (('Aigars', 'Daira'), ('Centis', 'Baiba'), ('Baiba', 'Centis')) | |
targets = list(people) | |
random.shuffle(targets) | |
pairs = zip(people, targets) # zip( [A, B, C], [1, 2, 3] ) = [[A, 1], [B, 2], [C, 3]] | |
while( [1 for banned_pair in banned if banned_pair in pairs] or [1 for person in people if (person, person) in pairs] ): | |
print "retrying" | |
random.shuffle(targets) | |
pairs = zip(people, targets) | |
print pairs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment