Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. discounts = { 1: 1, 2: 0.95, 3: 0.90, 4: 0.80, 5: 0.75, }
  2.  
  3. def get_price(books):
  4.     sets = []
  5.     for book in books:
  6.         for set in sets:
  7.             if book not in set:
  8.                 set.append(book)
  9.                 break
  10.         else:
  11.             sets.append([book])
  12.  
  13.     total_price = 0
  14.     for set in sets:
  15.         total_price += (len(set) * 8) * discounts[len(set)]
  16.  
  17.     return total_price
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement