This code has the goal to pick santa secret couples. In the case of this project you can configure that there is some participants can not do gift to someone , imagine in a group there is a couple of wife and husband. The algorithm can fail because there is a black list condition . So if fails will not send the emails , and then you can execute again. Enjoy!
node santa_algorithm.js
Use nodemailer to send emails from your node js server
[
{email:"[email protected]",name:"NAME",blackList:["[email protected]","[email protected]"]},
{email:"[email protected]",name:"NAME",blackList:[]},
{email:"[email protected]",name:"NAME",blackList:["[email protected]"]},
{email:"[email protected]",name:"NAME",blackList:["[email protected]"]},
{email:"[email protected]",name:"NAME",blackList:[]},
{email:"[email protected]",name:"NAME",blackList:["[email protected]"]},
{email:"[email protected]",name:"NAME",blackList:["[email protected]"]},
{email:"[email protected]",name:"NAME",blackList:[]},
]
{
email:"EMAIL_PARTICIPANT",
name:"NAME_PARTICIPANT",
blackList:[...AN ARRAY OF PARTICIPANTS THAT CAN NOT BE A RECEVIER OF THIS PARTICIPANT]
},
[{email:"EMAIL WHO S GIFT", name: "NAME WHO S GIFT"},{email:"EMAIL WHO S RECEIVE", name:"NAME WHO S RECEIVE"}]