<jupyter_start><jupyter_text>Remove banned pairsSometimes you may wish to ban certain pairs of players from a matching. This can be done by removing them from the game all together.Consider the following preferences from an instance of HR.<jupyter_code>resident_prefs = {
    "A": ["C"],
    "S": ["C", "M"],
    "D": ["C", "M", "G"],
    "J": ["C", "G", "M"],
    "L": ["M", "C", "G"],
}

hospital_prefs = {
    "M": ["D", "L", "S", "J"],
    "C": ["D", "A", "S", "L", "J"],
    "G": ["D", "J", "L"],
}<jupyter_output><empty_output><jupyter_text>The pairs to be removed can be described as a list of hospital-resident tuples. This list needs to be iterated, and the preferences updated.<jupyter_code>banned_pairs = [("M", "L"), ("C", "J")]
for hospital, resident in banned_pairs:

    hprefs = hospital_prefs[hospital]
    rprefs = resident_prefs[resident]

    if resident in hprefs:
        hprefs.remove(resident)
        hospital_prefs[hospital] = hprefs
    if hospital in rprefs:
        rprefs.remove(hospital)
        resident_prefs[resident] = rprefs
resident_prefs, hospital_prefs<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1641391614629795, 'fraction_numerical': 0.0, 'mean_word_length': 4.054054054054054, 'pattern_counts': {'":': 8, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '437224', 'license': 'MIT', 'n_tokens_mistral': 406, 'n_tokens_neox': 390, 'n_words': 121, 'path': 'docs/how-to/remove_banned_pairs.ipynb', 'repo_name': 'samf1986/matching', 'size': '1121'}