There is a certain amount, there is a set of goods with different prices. Tell me how to find any set of products so that their amount is the desired amount. Ie you need to dial the goods exactly for this amount, while the prices are different and the number of goods can be arbitrary. Which way to think? All data is retrieved from the sql database using php, i.e. we have a ready-made selection of goods with their price and quantity.

  • one
    Goods piece or, like, weighed out granulated sugar? :) - Harry
  • As far as I remember, the discrete version of this problem is NP-complete, so it seems that the exact solution is just a brute force ... Optimization, as I understand it, is not of interest? (Type - to collect more and more goods by quantity or by weight) - Harry
  • @Harry, goods are only piece goods without weight, no matter what the quantity is, the goods will be collected as a result, the main thing is to get the necessary amount. But the number of goods is limited, you need to take this into account. - alexey romashev
  • one
    Well, the typical NP-complete problem of integer linear programming ... - Harry

0