Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 05. Dragon Army Dictionaries - More Exercises 100/100
- # https://judge.softuni.org/Contests/Practice/Index/1738#4
- n_dragons = int(input())
- my_dragons = {}
- for _ in range(n_dragons):
- details = input().split()
- color_type = details[0]
- name = details[1]
- if not name[0].isupper():
- continue
- damage = details[2]
- if damage == 'null':
- damage = 45
- else:
- damage = int(damage)
- health = details[3]
- if health == 'null':
- health = 250
- else:
- health = int(health)
- armor = details[4]
- if armor == 'null':
- armor = 10
- else:
- armor = int(armor)
- if color_type not in my_dragons:
- my_dragons[color_type] = {name: [damage, health, armor]}
- else:
- if name not in my_dragons[color_type]:
- my_dragons[color_type].update({name: [damage, health, armor]})
- else:
- my_dragons[color_type].update({name: [damage, health, armor]})
- for key, value in my_dragons.items():
- average_sum = [0, 0, 0]
- for dragon, stats in value.items():
- for index, el in enumerate(stats):
- average_sum[index] += el / len(value)
- print(key, end="::")
- result = ('/'.join([f"{el:.2f}" for el in average_sum]))
- print(f"({result})")
- for dragon1, stats1 in sorted(value.items(), key=lambda x: x[0]):
- result = f"-{dragon1} -> damage: {stats1[0]}, health: {stats1[1]}, armor: {stats1[2]}"
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement