Every year my family does a gift exchange. Names are chosen out of a hat to randomly assign pairs. Certain rules are followed:
- give to a different person than last year
- partners can’t be nuclear family members (or bf/gf/so/etc.)
- can’t choose yourself
- participants give one gift only
- participants receive one gift only
I decided to give it the old college try in Python. Drawing names following the rules certainly posed more of a challenge than I anticipated! But I think I figured it out. At least, I figured out the “lazy programmer” way to solve it, not the statistician/np-complete/combinatorial/elegant mathy way to solve it.
(more…)