Answer the question
In order to leave comments, you need to log in
What is the best way to organize the benefit calculation algorithm?
Given:
A standard basket of goods in a store
Answer the question
In order to leave comments, you need to log in
You need to formalize the task. Carefully, with formulas, describe all types of promotional codes, how they work and interact.
If all promo codes gave a percentage discount, then you could take it greedily, but these absolute codes break everything. Here you can see not the solution of the problem of a backpack or the exchange of coins (dynamic programming), it seems that this will speed up the solution. It seems like - they sorted out which percentage codes you use and now you have the amount X. You need to dial the maximum number no more than X with absolute codes.
And so you will have to do a complete enumeration at least partially. This recursive function will have to be implemented - google "brute force" even here.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question