Secret Santa Assignment
Problem Given a list of people, produce a random Giver -> Receiver assignment (a derangement) in which no one is assigned to themselves. Every person gives exactly one gift and receives exactly one.
Input / Output
- Input: a list of people.
- Output: a map giver -> receiver where no key equals its value, and every person appears once as a giver and once as a receiver.
Constraints
- No self-assignment.
- Every person gives once and receives once (a permutation with no fixed point).
- With >= 2 people a valid assignment always exists.
Example
- [A,B,C] -> {A:B, B:C, C:A} (a cyclic assignment; other derangements are valid too).
added …