Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- discounts = { 1: 1, 2: 0.95, 3: 0.90, 4: 0.80, 5: 0.75, }
- def get_price(books):
- sets = []
- for book in books:
- for set in sets:
- if book not in set:
- set.append(book)
- break
- else:
- sets.append([book])
- total_price = 0
- for set in sets:
- total_price += (len(set) * 8) * discounts[len(set)]
- return total_price
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement