bounslay

Untitled

May 20th, 2023
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. # The standard price per pair is 100 units.
  2. # The threshold is 40 units.
  3. # The discount per purchase is 10 units.
  4. # Finally, a client's budget is 550.
  5. # The client will be able to purchase a total of 8 pairs of socks for a total of 530 units and 20 units of change. The first pair will cost the full standard price - 100 units.
  6. # The second one will cost the standard price minus the discount - 90 units. The third pair will cost 80 units due to the discount accumulating with every purchase. The final bill
  7. # calculation will look like this: 100+90+80+70+60+50+40+40=530 units.
  8.  
  9. # Input
  10. # 550
  11. # 100
  12. # 10
  13. # 40
  14.  
  15. # Output
  16. # 8,20
  17.  
  18.  
  19. client_budget = int(input())
  20. standard_price = int(input())
  21. discount_price = int(input())
  22. price_threshold = int(input())
  23.  
  24.  
  25. lst = []
  26. while standard_price > price_threshold:
  27.     lst.append(standard_price)
  28.  
  29.     standard_price -= discount_price
  30.  
  31. sum_without_threshold = sum(lst)
  32.  
  33.  
  34. change = 0
  35. while sum_without_threshold < client_budget:
  36.     sum_without_threshold += price_threshold
  37.    
  38.     if sum_without_threshold <= client_budget:
  39.         lst.append(price_threshold)
  40.     else:
  41.         break
  42.    
  43.  
  44. if len(lst) >= 10:
  45.     lst.append(0)
  46.  
  47.  
  48. change = client_budget - sum(lst)
  49.  
  50. print(f"{len(lst)}, {change}")
Advertisement
Add Comment
Please, Sign In to add comment