Secret Santa is NP-Complete (2006)
blogs.msdn.com
blogs.msdn.com
The problem you know is NP-complete has to be reduced to your Santa problem.
What OP described was mapping from Secret Santa to Hamiltonian circuit, not the other way around.
I've had a bunch of problems reduced to be solvable with approximation algorithms of NP-hard problems, that doesn't make them NP-hard, it's equivalent to solving a problem by reducing it to an NP-complete one with an exponential algorithm.
That's why it's not that simple to prove a problem NP-complete.
It might be that the problem is filled with symmetry and by modifying an algorithm for an NP-complete problem you get a polynomial one.
For example, Vehicle Routing Problem with Time Windows (multiple Hamiltonians with time windows) is considered NP-hard but if your locations had a lot of short time windows you can solve any instance in polynomial time (almost O(n)). But you can also solve it with any VRPTW algorithm (DP, PTAS, heuristics etc.).
Rather, he simply (incorrectly as others have pointed out) asserts a 1-1 map between his problem and the Hamiltonian circuit problem. IE: "A Hamiltonian circuit is a path that traverses an entire graph by visting each node exactly one time. It turns out that this is exactly the problem I was trying to solve. " (exactly his problem equals, has a 1-1 map to Hamiltonian circuits).
Edit: his problem doesn't map either way to the Hamiltonian graph problem - you could have two disjoint graphs that could be solved as Secret Santa problems but not as Hamiltonian graph problems.
It's true that if every NP problem were reducible to S.S., then it would be NP-hard, and as it can be verified in P time with the S.S. list and the list of people plus relations, and is thus in NP, it would also be NP-complete. It would also suffice to reduce an NP-complete problem to the S.S. problem as pictured here to prove NP-completeness.
But this article doesn't give proof of either and generally points in a different direction, like you said, so the title is really misleading and it would have been better to open the article with a question or discussion.
To summarize, this post by Rod Hilton is pretty useful in understanding the relation between P, NP, NP-hard, and NP-complete: http://www.nomachetejuggling.com/2012/09/14/traveling-salesm...
See http://cstheory.stackexchange.com/questions/8563/partition-a... for details.
A->B->C->A
D->E->F->D
Unfortunately real-life intervened and we didn't have time to decide if this was an NP complete problem or not...
Also, to show np completeness one must show reduction in both directions. I somehow doubt that any SAT-Problem is reducible to secret-santa, if secret santa isn't exactly hamiltonian cycle anyways.
This is one of the fun things, to me, about having a background/interest in the more theoretical sides of CS/mathematics as a programmer. The day you realize that half the problems you're working on are really already solved (or related to) problems on graphs or some other structure, and if you reorganize your models around this you can get a much cleaner implementation. Come up with a representation of your problem using a graph, run a well-known algorithm from a graph library, solution found (hopefully before Christmas).
This is the one major gap I've noticed between professional programmers with a CS academic background versus those from an engineering academic background. The gap is easily closed, but the engineers lack the random bits of extra discrete maths or CS theory to make these kind of connections. OTOH, I'm sure programmers from an engineering background can easily say the same from the other side using some other set of knowledge.
Meanwhile, graph theory was aware of a polynomial-time solution to the guy's actual problem all along.
Here's how you do secret santa: take a list of people, shuffle the list, each person buys for the next person on the list, last person buys for the first person. Polynomial time.
This ultimately led me to create a TSP solving library that implemented a bunch of the known heuristic algorithms to approximate the solution. Worked out pretty well in the end and learned lots while I was at it.
Usually the easiest is to just use Fisher-Yates to get a random permutation and reject it if it doesn't fit the criteria (people shouldn't pick themselves etc.). For nearly all practical problem sizes this should be fast enough.
Trying to reject permutation half way and fixing it has a tendency to cause subtle biases.
generate a hash (e.g. md5) of current year (or 'draw' if you do secret santa
once a month) and each person's name
sort the people by their hashes
draw 1 and 2 together, 3 and 4, etc.If there is a conflict with the last 2 people, you need to start over.