Skip to content

Instantly share code, notes, and snippets.

@mahmoudhossam
Created November 6, 2011 09:38
Show Gist options
  • Save mahmoudhossam/1342696 to your computer and use it in GitHub Desktop.
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.
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