Advertisement
pacho_the_python

Aladdin's Gifts

May 21st, 2022
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. from collections import deque
  2.  
  3.  
  4. materials = deque(map(int, input().split()))
  5. magic_level = deque(map(int, input().split()))
  6.  
  7. gem = 0
  8. porcelain = 0
  9. gold = 0
  10. diamond = 0
  11. result = 0
  12.  
  13. while materials and magic_level:
  14.     material = materials.pop()
  15.     magic = magic_level.popleft()
  16.     result = material + magic
  17.  
  18.     if result < 100:
  19.         if result % 2 == 0:
  20.             result = material * 2 + magic * 3
  21.         else:
  22.             result = material * 2 + magic * 2
  23.     elif result > 499:
  24.         result = material / 2 + magic / 2
  25.  
  26.     if 100 <= result <= 199:
  27.         gem += 1
  28.     elif 200 <= result <= 299:
  29.         porcelain += 1
  30.     elif 300 <= result <= 399:
  31.         gold += 1
  32.     elif 400 <= result <= 499:
  33.         diamond += 1
  34.  
  35. if (gem > 0 and porcelain > 0) or (gold > 0 and diamond > 0):
  36.     print("The wedding presents are made!")
  37. else:
  38.     print("Aladdin does not have enough wedding presents.")
  39.  
  40. if materials:
  41.     print(f"Materials left: {', '.join(map(str, materials))}")
  42.  
  43. if magic_level:
  44.     print(f"Magic left: {', '.join(map(str, magic_level))}")
  45.  
  46. if gem:
  47.     print(f"Gemstone: {gem}")
  48. if porcelain:
  49.     print(f"Porcelain Sculpture: {porcelain}")
  50. if gold:
  51.     print(f"Gold: {gold}")
  52. if diamond:
  53.     print(f"Diamond Jewellery: {diamond}")
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement