Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. ebeebay is a online marketplace. A Seller in ebeebay wants to sell Q quantity for P price each.
  2. And there are many interested buyers - 1st buyer want to purchase Q1 quantities at P1 price each.
  3. and 2nd buyer wants to purchase Q2 qunaities at P2 price each. so on.. where Q = Q1 + Q2 + Q3 + ... + Qn.
  4. ebeebay is a neutral market place where it tries to find the mid price for both parties and make a best deal.
  5.  
  6. Example
  7. SELLER wants to sell 100 (Q) smartphones at 200$ (P) each = 20000$ total selling price
  8. BUYER1 wants to buy 60 (Q1) smartphones at 220$ (P1) = 13200$ total buying price
  9. BUYER2 wants to buy 40 (Q2) smartphones at 210$ (P2) = 8400$ total buying price
  10.  
  11. caclculate mid price for each deal
  12. SELLER & BUYER1 deal - 60 smartphones at 210$ (200+220)/2 price each.
  13. SELLER & BUYER2 deal - 40 smartphones at 205$ (200+210)/2 price each.
  14.  
  15. 20800$ will be total selling price for SELLER (deal price)
  16. 12600$ will be total buying price for BUYER1
  17. 8200$ will be total buying price for BUYER2
  18.  
  19. Now complete below python program which takes 1 seller qty & price and n buyer qty & prices.
  20. 1. print total selling price
  21. 2. print each buyers total buying price
  22. 3. find best buyer who contributed highest buy to the deal.
  23.  
  24. class RetailOrder(object):
  25. def __init__(self, qty, price):
  26. self.qty = qty
  27. self.price = qty
  28.  
  29. # seller - 1 RetailOrder with qty & price
  30. # buyers - list of RetailsOrder's with qty & price
  31. # implement you deal making logic below
  32. def ebeebay_make_best_deal(seller, buyers)
  33. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement