Gift exhange is a small side project I built to help my family and friends participate in a gift exchange. This can lead to potential awkward situations where:
To solve this, I wrote a simple backtracking algorithm that finds the first Hamiltonian cycle it finds. The input array is shuffled to ensure that the solution is not deterministic.
The algorithm is simple:
The algorithm currently has the capability to specify a list of people each person can give a gift to, but the UI lacks this feature.