Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python3.7
- # -*- coding: utf-8 -*import
- import re
- text = input().split(',')
- def sanitize(a: list):
- b = sorted([x.strip() for x in a], key=lambda x: x)
- return b
- text = sanitize(text)
- for i in text:
- pattern = r'(?P<health>[^\+\-\*\/\.0-9])'
- match = re.findall(pattern, i)
- health = sum([ord(x) for x in match])
- pattern_dmg = r'(-?[0-9]+\.*[0-9]*)'
- dmg = sum([float(x) for x in re.findall(pattern_dmg, i)])
- for s in i:
- if s == '*':
- dmg *= 2
- elif s == '/':
- dmg /= 2
- print(f'{i} - {health} health, {dmg:.2f} damage')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement