evilpie
evilpie

Reputation: 2941

Fairly distribute a limited amount of things by how much they are wanted

So I have a set of users, who wish to get 1 items, but they can make 3 wishes, sorted by how much they want them. But the number of times one item can be given to away is limited across all users. In the end everybody should (possibly) get the item he wishes the most.

I already tried to add every user who wishes item X to a list of "wishers", if this list is smaller than the number available, everybody gets it. The problem is this doesn't respect how much somebody likes the item, if the number of items available is bigger.

I believe there might already a mathematical problem that tries to solve that.

Upvotes: 0

Views: 121

Answers (1)

Nader
Nader

Reputation: 5595

let's say you have 100 apples, bananas and carrots

and let's say you have 300 people, who have ranked their three choices.

a simple algorithm would be to try and fulfill everyone's first choice first. so let's say the first choices of the 300 people are: 150 apples, 120 bananas, 30 carrots. if the number of items available is less than the number desired good, everyone gets one. otherwise randomly distribute.

so in the example above you are able to fulfill the first choice of 230 people.

then go through second (and then third) choices of the people remaining and repeat.

Upvotes: 1

Related Questions