Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def maximum_cost(shop, total):
- final = [-1]
- def works(shopa, totala):
- if totala < 0:
- return False
- elif totala == 0:
- return True
- else:
- ans = False
- for bundleb in shopa:
- if works(shopa, totala - get_size(bundleb)):
- ans = True
- break
- return ans
- def recur(shopb, totalb):
- possible = []
- if totalb <= 0:
- return [0]
- else:
- for bundle in shopb:
- if works(shopb, totalb - get_size(bundle)) or totalb == 0:
- for i in recur(shopb, totalb - get_size(bundle)):
- possible.append(get_cost(bundle) + i)
- return possible
- for bundlea in shop:
- if is_pink_rose(bundlea):
- final.append(get_cost(bundlea) + max(recur(shop, total - get_size(bundlea))))
- return max(final)
- for bundlea in shop:
- if is_pink_rose(bundlea):
- final.append(get_cost(bundlea) + max(recurhelper(shop, total - get_size(bundlea))))
- return max(final)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement