The post-to-twitter link is not working
Hmm... Should be okay now.
Hahahahaha!! This one awesome.. ROFL.
kid with candy nearest to the one you stole candy from...
couldn't that be interpreted as the one you just stole from [if there's any candy left] since the distance from him to him would be 0?
Well, yes. The "if there's any candy left" is key. The greedy algorithm leaves no candy (and if the kids gets more candy and is still the closest... rob him again).
don't know about yours, but my friends would probably stop talking to me if I stole all their candy... then again, i could make new friends, but at the cost of some of my candy... :( its a sad, sad world we live in; a world where no man can keep his friends and have all their candy at the same time...
Greedy Algorithm: good for making change, bad for making friends
Halloween is for the needy not the greedy :P... Now I NEED all those candies ;)
This is far from optimal. You can create examples which are as bad as you want. Imagine a graph of kids (that have each only one candy bar) that lead you away from a kid with an arbitrary amount of candy, which would just be an infinitesimally small distance further away.
Bad algorithm. Bad!
But of course, nobody says that greedy is always the best (in fact it is usually not). Nonetheless, you should define the metric by which you measure how well you perform (is it amount of candy by total distance?).
"Better" Algorithm: Everyone walk to me and give me your candy. O(1) for parallel servers.
I think my professor wrote a paper on how to find a approximation for this...