Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- def is_crafted_gift(sum_, gifts_table_):
- for min_value, max_value in gifts_table_.keys():
- if min_value <= sum_ <= max_value:
- return gifts_table_[(min_value, max_value)]
- materials_stack = [int(n) for n in input().split()]
- magic_level_que = deque([int(n) for n in input().split()])
- gifts_table = {(100, 199): 'Gemstone',
- (200, 299): 'Porcelain Sculpture',
- (300, 399): 'Gold',
- (400, 499): 'Diamond Jewellery'}
- crafted_gifts = {'Gemstone': 0, 'Porcelain Sculpture': 0, 'Gold': 0, 'Diamond Jewellery': 0}
- while materials_stack and magic_level_que:
- current_material, current_magic = materials_stack.pop(), magic_level_que.popleft()
- current_sum = current_material + current_magic
- if current_sum < 100 and current_sum % 2 == 0:
- current_sum = current_material * 2 + current_magic * 3
- elif current_sum < 100:
- current_sum *= 2
- elif current_sum >= 500:
- current_sum /= 2
- current_gift = is_crafted_gift(current_sum, gifts_table)
- if current_gift:
- crafted_gifts[current_gift] += 1
- if (crafted_gifts['Gemstone'] and crafted_gifts['Porcelain Sculpture']) or \
- (crafted_gifts['Gold'] and crafted_gifts['Diamond Jewellery']):
- print("The wedding presents are made!")
- else:
- print("Aladdin does not have enough wedding presents.")
- if materials_stack:
- print(f"Materials left: {', '.join([str(n) for n in materials_stack])}")
- if magic_level_que:
- print(f"Magic left: {', '.join([str(n) for n in magic_level_que])}")
- for gift, quantity in sorted(crafted_gifts.items()):
- if quantity:
- print(f"{gift}: {quantity}")
Advertisement
Add Comment
Please, Sign In to add comment