I have a request to purchase the product from a customer.
I'd like to change that product to the best set of products and buy it at the lowest price.
Please let me know if you have a good algorithm.
Example)
Customer Purchase Request
Item A 20 unit price 200 yen Total price 4000 yen
Item B Unit price 300 yen Total price 3000 yen
Set item
Product AB Set Price 450 Yen
Breakdown
Product A 1 ea
Item B 1p
In the above case, it is best for the customer to purchase 10 units of product AB set and 10 units of product A as a single item.
Please let me know if there is a good algorithm to choose the best combination like this.
It does not matter what language the program is in.
Thank you for your cooperation.
If I'm right,
Always:
Product A (200 yen) + Product B (300 yen) > Product AB set (450 yen)
So the solution is:
Xa=Product A amount
Xb = Product B amount
if Xa>Xb
then
Purchase ← (Xa-Xb) Product A
Purchase ← (Xb) Product AB Set
else
Purchase ← (Xb-Xa) Product B
Purchase ← (Xa) Product AB Set
end
Wouldn't it be best to use dynamic planning for 0-1 knapsack problems?
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
582 PHP ssh2_scp_send fails to send files as intended
917 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.