kostovhg

Untitled

Jul 21st, 2021
814
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. number_of_inputs, dragons, default = int(input()), {}, {'damage': 45, 'health': 250, 'armor': 10}
  2.  
  3. for _ in range(number_of_inputs):
  4.     d_type, name, *int_values = input().split()
  5.     damage, health, armor = [int(x) if x != 'null' else -1 for x in int_values]
  6.     dragon = {'damage': damage, 'health': health, 'armor': armor}
  7.     for k in dragon:
  8.         if dragon[k] == -1:
  9.             dragon[k] = default[k]
  10.     dragons.setdefault(d_type, {})
  11.     dragons[d_type][name] = dragon
  12.  
  13. for d_type, d_list in dragons.items():
  14.     d_count = len(d_list)
  15.     avr_dmg, avr_hlt, avr_arm = [sum([dragon[key] for dragon in d_list.values()]) / d_count for key in default]
  16.     print(f"{d_type}::({avr_dmg:.2f}/{avr_hlt:.2f}/{avr_arm:.2f})")
  17.     for dragon in sorted([d for d in d_list]):
  18.         print(f"-{dragon} -> {', '.join([k +': ' + str(v) for k, v in d_list[dragon].items()])}")
RAW Paste Data