Created
April 14, 2018 16:53
-
-
Save paul-schwendenman/c29b13be6fac5a9b82b182088aea65b6 to your computer and use it in GitHub Desktop.
Pairings generator
This file contains hidden or 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 itertools | |
import functools | |
import random | |
a = itertools.permutations(['David', 'Dicko', 'Matt', 'Paul', 'Ryan'], 5) | |
def swapper(x): | |
y = list(x) | |
if x[0] > x[1]: | |
y[0], y[1] = x[1], x[0] | |
if x[2] > x[3]: | |
y[2], y[3] = x[3], x[2] | |
return (y[0], y[1], y[2], y[3], y[4]) | |
def swapper2(x): | |
y = list(x) | |
if x[0] > x[2]: | |
y[0], y[1] = x[2], x[3] | |
y[2], y[3] = x[0], x[1] | |
return (y[0], y[1], y[2], y[3], y[4]) | |
# def group_pairs(x): | |
# return ((x[0], x[1]), (x[2], x[3]), (x[4],)) | |
def ryan_not_alone(x): | |
return x[4] != 'Ryan' | |
a = map(swapper, a) | |
a = map(swapper2, a) | |
a = list(set(a)) | |
a = filter(ryan_not_alone, a) | |
# a = map(group_pairs, a) | |
random.shuffle(a) | |
for b in a: | |
print '{0} and {1}, {2} and {3}, {4}'.format(*b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment