Answer the question
In order to leave comments, you need to log in
Algorithm for selecting N items by price?
Good day, dear)
Faced the following task:
For example, we have 4 items (it can be as many as you like) and their price
is 1 - 5p
2 - 10p
3 - 5p
4 - 10p
The task is this, select items from here so that they satisfied the condition: the sum of the selected items = 30% (+ -5% (for example) of the total amount of items.
In this case, the following combinations are possible: 1.3 and 2. (The combination with a smaller number of items is in priority)
That is, you need get the combination of items as close as possible to N% of the total amount.Has
anyone come across similar algorithms?
Any examples of solutions/algorithms?
I suppose that first you need to build all combinations without repetitions, and from them already choose the most suitable combination?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question