Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1
- from collections import deque
- materials = [int(x) for x in input().split()]
- magic_level = deque([int(x) for x in input().split()])
- doll_magic_needed = 150
- wooden_train_magic_needed = 250
- teddy_bear_magic_needed = 300
- bicycle_magic_needed = 400
- possible_toys = {"Doll": doll_magic_needed, "Wooden train": wooden_train_magic_needed,
- "Teddy bear": teddy_bear_magic_needed, "Bicycle": bicycle_magic_needed}
- created_toys = []
- def check_for_matches(sum_):
- for key, value in possible_toys.items():
- if value == sum_:
- created_toys.append(key)
- while materials and magic_level:
- material = materials.pop()
- magic = magic_level.popleft()
- total_magic = magic * material
- if total_magic in possible_toys.values():
- check_for_matches(total_magic)
- else:
- if total_magic < 0:
- new_material = magic + material
- materials.append(new_material)
- elif total_magic > 0:
- materials.append(material + 15)
- else:
- if magic == 0 and material == 0:
- continue
- elif magic == 0:
- materials.append(material)
- else:
- magic_level.appendleft(magic)
- if (("Teddy bear" in created_toys and "Bicycle" in created_toys)
- or ("Doll" in created_toys and "Wooden train" in created_toys)):
- print("The presents are crafted! Merry Christmas!")
- else:
- print("No presents this Christmas!")
- materials_left = ", ".join(str(x) for x in materials)
- magic_left = ", ".join(str(x) for x in magic_level)
- if materials:
- print(f"Materials left:", end=" ")
- for i in range(len(materials) - 1, -1, -1):
- if i == 0:
- print(materials[i], end=" ")
- else:
- print(materials[i], end=", ")
- print('')
- if magic_level:
- print(f"Magic left:", end=" ")
- for i in range(len(magic_level)):
- if i == len(magic_level) - 1:
- print(magic_level[i], end=" ")
- else:
- print(magic_level[i], end=", ")
- print('')
- sorted_created = sorted(set(created_toys))
- for i in sorted_created:
- print(f"{i}: {created_toys.count(i)}")
- *2
- # 100/100
- # from collections import deque
- #
- # materials = [int(x) for x in input().split()]
- # magic_level = deque([int(x) for x in input().split()])
- #
- # doll_magic_needed = 150
- # wooden_train_magic_needed = 250
- # teddy_bear_magic_needed = 300
- # bicycle_magic_needed = 400
- #
- # possible_toys = {"Doll": doll_magic_needed, "Wooden train": wooden_train_magic_needed,
- # "Teddy bear": teddy_bear_magic_needed, "Bicycle": bicycle_magic_needed}
- # created_toys = []
- #
- #
- # def check_for_matches(sum_):
- # for key, value in possible_toys.items():
- # if value == sum_:
- # created_toys.append(key)
- #
- #
- # while materials and magic_level:
- # material = materials.pop()
- # magic = magic_level.popleft()
- # total_magic = magic * material
- #
- # if total_magic in possible_toys.values():
- # check_for_matches(total_magic)
- #
- # else:
- # if total_magic < 0:
- # new_material = magic + material
- # materials.append(new_material)
- # elif total_magic > 0:
- # materials.append(material + 15)
- #
- # else:
- # if magic == 0 and material == 0:
- # continue
- # elif magic == 0:
- # materials.append(material)
- # else:
- # magic_level.appendleft(magic)
- #
- # if (("Teddy bear" in created_toys and "Bicycle" in created_toys)
- # or ("Doll" in created_toys and "Wooden train" in created_toys)):
- # print("The presents are crafted! Merry Christmas!")
- # else:
- # print("No presents this Christmas!")
- #
- #
- # if materials:
- # materials = materials[::-1]
- # print(f"Materials left: {', '.join(map(str, materials))}")
- #
- # if magic_level:
- # print(f"Magic left: {', '.join(map(str, magic_level))}")
- #
- # sorted_created = sorted(set(created_toys))
- #
- # for i in sorted_created:
- # print(f"{i}: {created_toys.count(i)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement