Advertisement
simeonshopov

Nether Realms

Mar 17th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. #!/usr/local/bin/python3.7
  2. # -*- coding: utf-8 -*import
  3. import re
  4.  
  5. text = input().split(',')
  6.  
  7.  
  8. def sanitize(a: list):
  9.     b = sorted([x.strip() for x in a], key=lambda x: x)
  10.     return b
  11.  
  12.  
  13. text = sanitize(text)
  14.  
  15. for i in text:
  16.     pattern = r'(?P<health>[^\+\-\*\/\.0-9])'
  17.     match = re.findall(pattern, i)
  18.     health = sum([ord(x) for x in match])
  19.     pattern_dmg = r'(-?[0-9]+\.*[0-9]*)'
  20.     dmg = sum([float(x) for x in re.findall(pattern_dmg, i)])
  21.     for s in i:
  22.         if s == '*':
  23.             dmg *= 2
  24.         elif s == '/':
  25.             dmg /= 2
  26.     print(f'{i} - {health} health, {dmg:.2f} damage')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement