I don't know the problem name exactly, but it should be related to stock investment strategy. I have budget A = 30 Consider this list: myList = [[10,15], [11,13], [9,10]] for each element the first is expected return value, and second is the price.
Buying the first and second items maximize the return [10,15], [11,13] as 13 + 15 < 30 and return value is 21.
I have prioritize them based on value per price:
-------------
9, 10, 0.9
11, 13, 0.846
10, 15, 0.666
-------------
I Try to pick elements until my budget cannot afford element. Of course, this is not the right answer since it return [9,10], [11,13] and value 20.
I would appreciate any hint or link or even problem name.
I think you have posed the knapsack problem:
The problem is essentially difficult (in a well defined technical sense). There are clever computer programs that find the answer, but for long lists they are not as fast as you'd hope.
https://en.wikipedia.org/wiki/Knapsack_problem