#random #secret-santa #bipartite-graphs #gifts #wichteln


Resolve Secret Santa assignments with additional constraints

1 unstable release

Uses old Rust 2015

0.1.0 Oct 22, 2017

#282 in #random

Used in rusty-santa-cli


249 lines

Rusty Santa

A small Rust library (and command-line tool) for resolving Secret Santa assignments with additional constraints.

It is possible to add the following constraints to the random assignments:

  • Person A and B should not draw each other (e.g. for couples)
  • Person A should not draw person B (e.g. if person B already received a gift from person A the previous year, or if person A dislikes person B)

While this is an interesting mathematical problem and can be solved with bipartite graphs and the hungarian algorithm, this library sticks to a simpler approach and tries to emulate the real name drawing from a basket. Up to 1000 attempts are made at resolving the name assignments without conflict until the algorithm fails.