Created
November 6, 2011 09:38
-
-
Save mahmoudhossam/1342696 to your computer and use it in GitHub Desktop.
A function that takes two equal-sized sets, returns a set of pairs of the elements of the two sets.
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 copy | |
def mating_pairs(m, f): | |
males = copy.deepcopy(m) | |
females = copy.deepcopy(f) | |
pairs = set() | |
for i in m: | |
pairs.add((males.pop(), females.pop())) | |
return pairs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment