Skip to content

Instantly share code, notes, and snippets.

@ThomasParistech
Created January 15, 2022 10:13
Show Gist options
  • Save ThomasParistech/64a2b739ec69cd00503ff2a3ef6b06b2 to your computer and use it in GitHub Desktop.
Save ThomasParistech/64a2b739ec69cd00503ff2a3ef6b06b2 to your computer and use it in GitHub Desktop.
Secret santa final
import fire
from email_sender import EmailSender
from players_info import ListOfPlayerInfo
def main(players_json: str,
mail_address: str,
mail_pwd: str,
mail_txt: str):
"""
Find an optimal Secret Santa draw
and notify participants by email.
Args:
players_json: JSON file containing players information
mail_adress: Secret Santa's mail address
mail_pwd: Secret Santa's mail password
mail_txt: TXT file containing the object and body of the mail template
"""
email_sender = EmailSender(mail_address, mail_pwd, mail_txt)
players = ListOfPlayerInfo.load(players_json)
id_chain = solve(players)
if id_chain is None:
print("Impossible to link players.")
exit(1)
links = zip(id_chain, id_chain[1:] + id_chain[0])
email_sender.send_mails(players, links)
if __name__ == "__main__":
fire.Fire(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment