Advertisement
GeorgiLukanov87

Dictionaries - Exercise - 05. Legendary Farming 100/100

Jul 5th, 2022
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. # 05. Legendary Farming 100/100
  2. # Dictionaries - Exercise
  3. # https://judge.softuni.org/Contests/Compete/Index/1737#4
  4.  
  5.  
  6. materials = input()
  7. legendary = {'shards': 'Shadowmourne', 'fragments': 'Valanyr', 'motes': 'Dragonwrath'}
  8. key_materials = {'shards': 0, 'fragments': 0, 'motes': 0}
  9. junk = {}
  10. obtained = False
  11. final_print = ""
  12. while not obtained:
  13.     details = materials.split(' ')
  14.     for index in range(0, len(details), 2):
  15.         amount = int(details[index])
  16.         material = details[index + 1].lower()
  17.         if material in legendary.keys():
  18.             key_materials[material] += amount
  19.             if key_materials[material] >= 250:
  20.                 key_materials[material] -= 250
  21.                 final_print = legendary[material]
  22.                 obtained = True
  23.                 print(f'{final_print} obtained!')
  24.                 break
  25.         else:
  26.             if material not in junk.keys():
  27.                 junk[material] = amount
  28.             else:
  29.                 junk[material] += amount
  30.  
  31.     if not obtained:
  32.         materials = input()
  33.  
  34. for key, value in key_materials.items():
  35.     print(f'{key}: {value}')
  36. for key, value in junk.items():
  37.     print(f'{key}: {value}')
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement