# Introduction

There is a war and nobody knows - the alphabet war!  
There are two groups of hostile letters. The tension between left side letters and right side letters was too high and the war began. The letters called airstrike to help them in war - dashes and dots are spreaded everywhere on the battlefield.

# Task

Write a function that accepts `fight` string consists of only small letters and `*` which means a bomb drop place. Return who wins the fight after bombs are exploded. When the left side wins return `Left side wins!`, when the right side wins return `Right side wins!`, in other case return `Let's fight again!`.

The left side letters and their power:
```
 w - 4
 p - 3 
 b - 2
 s - 1
```
The right side letters and their power:
```
 m - 4
 q - 3 
 d - 2
 z - 1
```
The other letters don't have power and are only victims.  
The `*` bombs kills the adjacent letters ( i.e. `aa*aa` => `a___a`, `**aa**` => `______` );

# Example

# Alphabet war Collection



Alphavet war 


Alphabet war - airstrike - letters massacre


Alphabet wars - reinforces massacre


Alphabet wars - nuclear strike


Alphabet war - Wo lo loooooo priests join the war

Difficulty: introductory

Starter code:

def alphabet_war(fight):
	

Solutions:
import re

powers = {
    'w': -4, 'p': -3, 'b': -2, 's': -1,
    'm': +4, 'q': +3, 'd': +2, 'z': +1,
}

def alphabet_war(fight):
    fight = re.sub('.(?=\*)|(?<=\*).', '', fight)
    result = sum(powers.get(c, 0) for c in fight)
    if result < 0:
        return 'Left side wins!'
    elif result > 0:
        return 'Right side wins!'
    else:
        return "Let's fight again!"

def alphabet_war(fight):

  s = 'wpbsszdqm'
  alive = []

  if '*' not in fight[:2]:
    alive.append(fight[0])

  for i, c  in enumerate(fight[1:], 1):
    if '*' not in fight[i-1:i+2]:
      alive.append(c)
  
  x = sum(4 - s.index(c) for c in alive if c in s)
  return 'Let\'s fight again!' if x==0 else ['Left','Right'][x<0] + ' side wins!'

import re

def alphabet_war(fight):
    pattern = re.compile(r"(\w)?\*+(\w)?")
    powers = pattern.sub("", fight)
    scores = "mqdz*sbpw" 
    score = sum(i * powers.count(p) for i, p in enumerate(scores, -4))
    return ["Let's fight again!", "Left side wins!", "Right side wins!"][(score>0)-(score<0)]

import re

POWERS  = {c:i for i,c in enumerate('wpbs zdqm',-4)}
PATTERN = re.compile(r'(?<!\*)([{}])(?!\*)'.format(''.join(POWERS.keys()-{' '})))

def alphabet_war(fight):
    s = sum(POWERS[c] for c in PATTERN.findall(fight))
    return ["Let's fight again!", 'Left side wins!', 'Right side wins!'][ (s<0) - (s>0) ]

import re 
le = {"w":4,"p":3,"b":2,"s":1}
ri = {"m":4,"q":3,"d":2,"z":1}
def alphabet_war(fight):
    w = re.sub(r"[a-z]\*[a-z]|[a-z]\*|\*[a-z]","",fight)
    l = sum([le.get(i,0) for i in w])
    r = sum([ri.get(i,0) for i in w])
    if l==r:
        return "Let's fight again!"
    return "Right side wins!" if r>l else "Left side wins!"

import re
def alphabet_war(fight):
    d = {a : c for c, a in enumerate('wpbs zdqm', -4) if c}
    s = sum(d.get(a, 0) for a in re.sub(r'.?\*+.?', '', fight))
    return ['Left side wins!', "Let's fight again!", 'Right side wins!'][1 + min(max(s, -1), 1)]

def alphabet_war(fight):

    left_side = 'wpbs'
    right_side = 'mqdz' 
    left_power = 0
    right_power = 0
    bombs = [ i for i in range(0,len(fight)) if fight[i] =='*']  
    death = []
    
    for boom in bombs:
        if 0<boom<len(fight)-1:
            death.append(boom-1)
            death.append(boom+1)
        elif boom == 0:
            death.append(boom+1)
        elif boom ==len(fight)-1:
            death.append(boom-1)
                             
    bombs_and_death = bombs + death
    
    after_fight = ''.join(fight[i] if i not in bombs_and_death else '' for i in range(0,len(fight)))
      
    for i in after_fight:
        if i == 'w' or i =='m': 
            pow = 4 
        elif i == 'p' or i =='q': 
            pow = 3 
        elif i == 'b' or i =='d': 
            pow = 2 
        elif i == 's' or i =='z': 
            pow = 1 
        
        if i in left_side:
        # 'wpbs'
            left_power+=pow
        elif i in right_side:
        # 'mqdz' 
            right_power+=pow
    
    if left_power>right_power:
        return 'Left side wins!'
    elif right_power>left_power:
        return 'Right side wins!'
    else:
        return '''Let's fight again!'''

from functools import partial
from numpy import sign
from re import compile

remove = partial(compile(r".?\*+.?").sub, "")
memo = {'w':4, 'p':3, 'b':2, 's':1, 'm':-4, 'q':-3, 'd':-2, 'z':-1}
result = ("Let's fight again!", "Left side wins!", "Right side wins!")
value = lambda c: memo.get(c, 0)

def alphabet_war(fight):
    return result[sign(sum(map(value, remove(fight))))]

def alphabet_war(fight):
    sides = { 'left':{ 'w':4,'p':3,'b':2,'s':1 }, 'right':{ 'm':4,'q':3,'d':2,'z':1 } }
    
    left, right = ['Left',0],['Right',0]
    
    fild = [' '] * (len(fight) +2)
    
    for i,e in enumerate(' '+fight+' '):
        if e == '*':
            fild[i-1:i+2] = ['_','_','_']
        elif e != '*' and fild[i] != '_': 
            fild[i] = e 

    for e in fild:
        left[1]  += sides['left' ].get( e, 0 )
        right[1] += sides['right'].get( e, 0 )
    
    winer = max([left, right], key = lambda e:e[1] )
    
    return "Let's fight again!" if left[1] == right[1] else f'{winer[0]} side wins!'