Last active
May 17, 2017 14:14
-
-
Save EthanRosenthal/d9a654fca85768c48f6757475cbfe078 to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"num_pairs = 50\n", | |
"num_antipairs = 30\n", | |
"pair_constr = set()\n", | |
"anti_constr = set()\n", | |
"\n", | |
"pair_constr.add(tuple(sorted((bride, groom))))\n", | |
"\n", | |
"while len(pair_constr) < num_pairs:\n", | |
" guest_a, guest_b = np.random.choice(guests, \n", | |
" size=2, \n", | |
" replace=False)\n", | |
" pair = tuple(sorted((guest_a, guest_b)))\n", | |
" pair_constr.add(pair)\n", | |
"\n", | |
"while len(anti_constr) < num_antipairs:\n", | |
" guest_a, guest_b = np.random.choice(guests, \n", | |
" size=2, \n", | |
" replace=False)\n", | |
" anti_pair = tuple(sorted((guest_a, guest_b)))\n", | |
" if anti_pair not in pair_constr:\n", | |
" anti_constr.add(anti_pair)" | |
] | |
} | |
], | |
"metadata": { | |
"anaconda-cloud": {}, | |
"kernelspec": { | |
"display_name": "Python [conda root]", | |
"language": "python", | |
"name": "conda-root-py" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment