Who Buys The Croissants?

July 30, 2013

There was a big buzz on Stack Overflow recently when a question about buying croissants was asked:

At my office someone buys croissants for everybody every Friday. Sometimes we have problems arranging a suitable schedule because of absences — illness, vacation, training, customer meetings — so we’re looking for an algorithm that randomly chooses the person who should bring croissants so that everyone buys and consumes about as many croissants as everyone else.

The question caused a big ruckus at Stack Overflow, and is currently locked while the community decides if the question is appropriate; I personally think that it is, and further, that the question is both fun and practical.

Your task is to devise a suitable algorithm for deciding who should buy croissants, and demonstrate by simulation that your algorithms is fair. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2

2 Responses to “Who Buys The Croissants?”

  1. phil said

    so it sounds like your just looking for a uniform rng.
    here’s one that outputs a random schedule.
    http://pastebin.com/yUV1kEDT

  2. Richard A. O'Keefe said

    This is not a well-posed problem. When is the decision to be made? Is it fair to pick someone if in the future it turns out that they will never have eaten any croissants? What information do we have about how many croissants each individual is likely to eat? If someone buys a batch of croissants that nobody wants to eat, what happens? Since Uber Eats and similar services exist, is it really fair to exclude someone from purchasing just because they’re absent today, even if they’ve hogged most of the croissants in the past?

Leave a comment