Skip to content

Instantly share code, notes, and snippets.

@ThomasParistech
Created January 15, 2022 09:07
Show Gist options
  • Save ThomasParistech/94a497451cf8e52e60adbba863692fab to your computer and use it in GitHub Desktop.
Save ThomasParistech/94a497451cf8e52e60adbba863692fab to your computer and use it in GitHub Desktop.
Secret santa _init_possible_recipients
from players_info import ListOfPlayerInfo
from typing import List
def _init_possible_recipients(players: ListOfPlayerInfo) -> List[List[int]]:
"""
Apply inclusion and exclusion lists
to get all possible recipients for each player.
"""
all_names = [player.name for player in players]
possible_ids: List[List[int]] = [
[idx for idx, other_name in enumerate(all_names)
if other_name != player.name and
(len(player.include) == 0 or other_name in player.include) and
player not in player.exclude]
for player in players]
return possible_ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment