Advertisement
horozov86

Santa's Present Factory

May 18th, 2023
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | None | 0 0
  1. from _collections import deque
  2.  
  3. materials = [int(x) for x in input().split()]
  4. magic_level = deque([int(x) for x in input().split()])
  5.  
  6. presents = {}
  7. while materials and magic_level:
  8.     box = materials.pop()
  9.     magic = magic_level.popleft()
  10.  
  11.     total_magic_level = box * magic
  12.     if total_magic_level == 150:
  13.         if "Doll" not in presents:
  14.             presents["Doll"] = 0
  15.         presents["Doll"] += 1
  16.  
  17.     elif total_magic_level == 250:
  18.         if "Wooden train" not in presents:
  19.             presents["Wooden train"] = 0
  20.         presents["Wooden train"] += 1
  21.  
  22.     elif total_magic_level == 300:
  23.         if "Teddy bear" not in presents:
  24.             presents["Teddy bear"] = 0
  25.         presents["Teddy bear"] += 1
  26.  
  27.     elif total_magic_level == 400:
  28.         if "Bicycle" not in presents:
  29.             presents["Bicycle"] = 0
  30.         presents["Bicycle"] += 1
  31.  
  32.     else:
  33.         if total_magic_level < 0:
  34.             result = box + magic
  35.             materials.append(result)
  36.         if total_magic_level > 0 and total_magic_level != 150 and total_magic_level != 250 and total_magic_level != 300 and total_magic_level != 400:
  37.             box += 15
  38.             materials.append(box)
  39.  
  40.         if box == 0 and magic == 0:
  41.             continue
  42.         if box == 0:
  43.             magic_level.appendleft(magic)
  44.             continue
  45.         if magic == 0:
  46.             materials.append(box)
  47.             continue
  48.  
  49. if "Doll" and "Wooden train" in presents or "Teddy bear" and "Bicycle" in presents:
  50.     print("The presents are crafted! Merry Christmas!")
  51. else:
  52.     print("No presents this Christmas!")
  53.    
  54. if materials:
  55.     materials_left = ', '.join([str(x) for x in reversed(materials)])
  56.     print(f"Materials left: {materials_left}")
  57.  
  58. if magic_level:
  59.  
  60.     print(f"Magic left: {', '.join([str(x) for x in magic_level])}")
  61.  
  62. for k, v in presents.items():
  63.     print(f"{k}: {v}")
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement