Created
January 15, 2022 09:07
-
-
Save ThomasParistech/94a497451cf8e52e60adbba863692fab to your computer and use it in GitHub Desktop.
Secret santa _init_possible_recipients
This file contains 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
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