#asknostr #programming #sets
I have a set of tuples (A, B).
I want to find the subset for which
- there is no other subset with a higher total sum of A and
- for which the average amount of B is above a threshold X.
What algorithm can I use here?
#asknostr #programming #sets
I have a set of tuples (A, B).
I want to find the subset for which
- there is no other subset with a higher total sum of A and
- for which the average amount of B is above a threshold X.
What algorithm can I use here?
Oh and there is a third restriction:
- all tuples for which B >= X should be part of the subset
The answer by the way was very simple: sort by descending density and loop over each item. Try to add id to the subset and if the average amount of B remains above X keep it added. If it isn’t, skip it and try with the next item until you went through all of them