Implementing a Secret Santa Program in Elixir

155
clicks
Implementing a Secret Santa Program in Elixir

Source: 0x7f.dev

Type: Post

The author, Andrei C., expresses the common holiday frustration of gift exchanges leading to unnecessary spending and unwanted presents. To address this, he suggests a Secret Santa system and uses Elixir to create an algorithm that generates pairings for the gift exchange. The requirements for the algorithm are that it must create pairs, not match people with themselves, and ensure that pairs are not reciprocal. Andrei's initial idea to use a graph database was abandoned in favor of a simpler solution involving creating a list of people with their email addresses, shuffling the list, rotating it, and then pairing up the two resulting lists. For an odd number of participants, the issue of uneven matchups arises, but this is circumvented by rotating the list in such a manner that all participants can be paired. In addition, Andrei discovered Resend, an Elixir client for sending emails, and added a function to send out the Secret Santa matches via email. The post ends with an acknowledgment of the Elixir community's support over the past year, and an invitation for better algorithms, hinting at potential flaws in the proposed solution. Andrei also mentions he will be speaking at FOSDEM '24 in Brussels.

© HashMerge 2024