Find out who's going to buy the croissants http://stackoverflow.com/questions/17807531/find-out-whos-going-to-buy-the-croissants
The question states that at their company, Florian Margaine has a rule: each one of us has to buy the croissants once in a while for everybody.
The question states that at their company, Florian Margaine has a rule: each one of us has to buy the croissants once in a while for everybody.
Now we'd like to be a little more regular about this. And last friday, both of us bought the croissants, and some almost went to the bin because there were too many. Hopefully, I sacrificed myself.
So, how is this related to StackOverflow? I want an algorithm to decide who's going to buy the croissants next week.
Now the difficulty is that some of us can be absent during a week or 2. Or just this friday. And the next week it's another. It's a company with people having vacation, and we have customers or off-days. Hence simple sorting is not good enough.
- The chosen person should be pseudo-random
- Noone should buy the croissants twice in a row
- Generally speaking, everyone should buy croissants as many times as the others
We can have a small script sitting on a server and having access to some kind of database, run with a cron to send a mail saying who's the next to bring croissants.
For the reference, there are 10 of us in the office. The algorithm should be able to scale up to 50 members without issue.