# 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.

# Task

Write a function that accepts `fight` string consists of only small letters and return who wins the fight. 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.

# 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

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def alphabet_war(fight):
	

Solutions:
def alphabet_war(fight):
	d = {'w': 4, 'p': 3, 'b': 2, 's': 1, 'm': -4, 'q': -3, 'd': -2, 'z': -1}
	r = sum((d[c] for c in fight if c in d))
	return {r == 0: "Let's fight again!", r > 0: 'Left side wins!', r < 0: 'Right side wins!'}[True]


def alphabet_war(fight):
	result = sum(('zdqm'.find(c) - 'sbpw'.find(c) for c in fight))
	return '{} side wins!'.format('Left' if result < 0 else 'Right') if result else "Let's fight again!"


def alphabet_war(fight):
	sum = 0
	for i in fight:
		if i == 'w':
			sum = sum + 4
		elif i == 'p':
			sum = sum + 3
		elif i == 'b':
			sum = sum + 2
		elif i == 's':
			sum = sum + 1
		elif i == 'm':
			sum = sum - 4
		elif i == 'q':
			sum = sum - 3
		elif i == 'd':
			sum = sum - 2
		elif i == 'z':
			sum = sum - 1
	if sum > 0:
		return 'Left side wins!'
	elif sum == 0:
		return "Let's fight again!"
	else:
		return 'Right side wins!'


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

def alphabet_war(fight):
	result = sum((POWER.get(c, 0) for c in fight))
	return "Let's fight again!" if not result else ['Left', 'Right'][result > 0] + ' side wins!'


POWERS = {c: i for (i, c) in enumerate('wpbs zdqm', -4)}

def alphabet_war(fight):
	stroke = sum((POWERS[c] for c in fight if c != ' ' and c in POWERS))
	return ['Left side wins!', "Let's fight again!", 'Right side wins!'][(stroke >= 0) + (stroke > 0)]


alphabet_war = lambda f: (lambda r: "Let's fight again!" if not r else 'Left side wins!' if r > 0 else 'Right side wins!')(sum(('mqdz sbpw'.index(l) - 4 if l in 'mqdzsbpw' else 0 for l in f)))


alphabet_war = lambda s, f=lambda x, y: sum((y.find(e) + 1 for e in x)): (lambda a, b: "Let's fight again!" if a == b else '{} side wins!'.format(['Left', 'Right'][b > a]))(f(s, 'sbpw'), f(s, 'zdqm'))


def alphabet_war(fight):
	(a, b) = ('sbpw', 'zdqm')
	(l, r) = (sum([a.find(x) + 1 for x in fight]), sum([b.find(y) + 1 for y in fight]))
	return 'Right side wins!' if l < r else 'Left side wins!' if r < l else "Let's fight again!"


from collections import defaultdict

def alphabet_war(fight):
	d = defaultdict(int)
	(d['w'], d['p'], d['b'], d['s'], d['m'], d['q'], d['d'], d['z']) = (4, 3, 2, 1, -4, -3, -2, -1)
	a = sum((d[x] for x in fight))
	return 'Left side wins!' if a > 0 else "Let's fight again!" if a == 0 else 'Right side wins!'


def alphabet_war(fight):
	(sides, winer) = ({'w': -4, 'p': -3, 'b': -2, 's': -1, 'm': 4, 'q': 3, 'd': 2, 'z': 1}, 0)
	for e in fight:
		winer += sides.get(e, 0)
	return ["Let's fight again!", 'Right side wins!', 'Left side wins!'][(winer >= 0) - (winer <= 0)]


def alphabet_war(fight):
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	rigth = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	leftp = 0
	rigthp = 0
	for e in fight:
		leftp += left.get(e, 0)
		rigthp += rigth.get(e, 0)
	if leftp > rigthp:
		return 'Left side wins!'
	elif rigthp > leftp:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	import re
	countleft = len(re.findall('w', fight)) * 4 + len(re.findall('p', fight)) * 3 + len(re.findall('b', fight)) * 2 + len(re.findall('s', fight)) * 1
	countright = len(re.findall('m', fight)) * 4 + len(re.findall('q', fight)) * 3 + len(re.findall('d', fight)) * 2 + len(re.findall('z', fight)) * 1
	if countleft == countright:
		return "Let's fight again!"
	elif countright > countleft:
		return 'Right side wins!'
	elif countleft > countright:
		return 'Left side wins!'


def alphabet_war(fight):
	left_side = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right_side = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	contador_izq = 0
	contador_dch = 0
	for i in fight:
		if i in left_side.keys():
			contador_izq += left_side[i]
		if i in right_side.keys():
			contador_dch += right_side[i]
	if contador_izq > contador_dch:
		return 'Left side wins!'
	elif contador_izq < contador_dch:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	a = list()
	b = list()
	left = dict(list(zip('wpbs', [4, 3, 2, 1])))
	right = dict(list(zip('mqdz', [4, 3, 2, 1])))
	for i in fight:
		if i == 'w' or i == 'p' or i == 'b' or (i == 's'):
			a.append(left[i])
		elif i == 'm' or i == 'q' or i == 'd' or (i == 'z'):
			b.append(right[i])
	if sum(b) > sum(a):
		return 'Right side wins!'
	elif sum(a) > sum(b):
		return 'Left side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left_letters = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right_letters = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	count_left = []
	count_right = []
	fight = list(map(str, fight))
	for e in fight:
		for (key, value) in list(left_letters.items()):
			if e == key:
				count_left.append(value)
	for e in fight:
		for (key, value) in list(right_letters.items()):
			if e == key:
				count_right.append(value)
	total_left = sum(count_left)
	total_right = sum(count_right)
	if total_left > total_right:
		return 'Left side wins!'
	elif total_left < total_right:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left_points = sum([{'w': 4, 'p': 3, 'b': 2, 's': 1}[l] for l in fight if l in {'w': 4, 'p': 3, 'b': 2, 's': 1}])
	right_points = sum([{'m': 4, 'q': 3, 'd': 2, 'z': 1}[l] for l in fight if l in {'m': 4, 'q': 3, 'd': 2, 'z': 1}])
	if left_points > right_points:
		return 'Left side wins!'
	elif left_points < right_points:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	sl = 0
	rl = 0
	for letter in fight:
		if letter in left.keys():
			sl += left[letter]
		elif letter in right.keys():
			rl += right[letter]
	if sl > rl:
		return 'Left side wins!'
	elif rl > sl:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	clash = sum(('sbpw'.find(e) - 'zdqm'.find(e) for e in fight))
	if clash > 0:
		return 'Left side wins!'
	elif clash < 0:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


LEFT = 'wpbs'[::-1]
RIGHT = 'mqdz'[::-1]

def sum_points(s):
	return sum([LEFT.find(e) - RIGHT.find(e) for e in s])

def alphabet_war(fight):
	suma = sum_points(fight)
	if suma > 0:
		return 'Left side wins!'
	elif suma < 0:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


LEFT = 'wpbs'[::-1]
RIGHT = 'mqdz'[::-1]

def points(s, dictionary):
	return sum([dictionary.find(e) + 1 for e in s])

def alphabet_war(fight):
	(left, right) = (points(fight, LEFT), points(fight, RIGHT))
	if left > right:
		return 'Left side wins!'
	elif right > left:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	leftSide = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	rightSide = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left = []
	right = []
	for letter in fight:
		left.append(leftSide.get(letter, 0))
		right.append(rightSide.get(letter, 0))
	if sum(left) == sum(right):
		return "Let's fight again!"
	elif sum(left) > sum(right):
		return 'Left side wins!'
	elif sum(left) < sum(right):
		return 'Right side wins!'


def alphabet_war(fight):
	points = 'mqdz*sbpw'
	score = sum((i * fight.count(p) for (i, p) in enumerate(points, -4)))
	if score == 0:
		return "Let's fight again!"
	return ['Left', 'Right'][score < 0] + ' side wins!'


def alphabet_war(fight):
	l = {'w': 4, 'p': 3, 'b': 2, 's': 1, 'm': -4, 'q': -3, 'd': -2, 'z': -1}
	a = 0
	for i in list(fight):
		a += 0 if i in 'acefghijklnortuvxy' else l[i]
	return "Let's fight again!" if a == 0 else ('Right ' if a < 0 else 'Left ') + 'side wins!'


def alphabet_war(fight):
	ls = ['s', 'b', 'p', 'w', 'z', 'd', 'q', 'm']
	(a, b) = (0, 0)
	for i in list(fight):
		if i in ls:
			if ls.index(i) > 3:
				a += ls.index(i) - 3
			else:
				b += ls.index(i) + 1
	return "Let's fight again!" if a == b else 'Right side wins!' if a > b else 'Left side wins!'


def alphabet_war(fight):
	left_side = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right_side = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	total = 0
	for char in fight:
		if char in list(left_side.keys()):
			total += left_side[char]
		elif char in list(right_side.keys()):
			total -= right_side[char]
		else:
			total += 0
	if total > 0:
		return 'Left side wins!'
	elif total < 0:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left_side = ('s', 'b', 'p', 'w')
	left_score = 0
	right_side = ('z', 'd', 'q', 'm')
	right_score = 0
	for c in fight:
		if c in left_side:
			left_score += left_side.index(c) + 1
		elif c in right_side:
			right_score += right_side.index(c) + 1
	return 'Right side wins!' if right_score > left_score else 'Left side wins!' if left_score > right_score else "Let's fight again!"


def alphabet_war(fight):
	left_power = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right_power = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left_sum = 0
	right_sum = 0
	for char in fight:
		if char in left_power:
			left_sum += left_power[char]
		elif char in right_power:
			right_sum += right_power[char]
	if left_sum > right_sum:
		return 'Left side wins!'
	elif left_sum < right_sum:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	dic1_left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	left_score = 0
	dic2_right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	right_score = 0
	no_score = 0
	for i in fight:
		if i in dic1_left:
			left_score += dic1_left[i]
		elif i in dic2_right:
			right_score += dic2_right[i]
		else:
			no_score += 0
	if left_score > right_score:
		return 'Left side wins!'
	elif left_score == right_score:
		return "Let's fight again!"
	else:
		return 'Right side wins!'


def alphabet_war(fight):
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	l = sum((left[i] for i in fight if i in left))
	r = sum((right[i] for i in fight if i in right))
	if l > r:
		return 'Left side wins!'
	if r > l:
		return 'Right side wins!'
	return "Let's fight again!"


def alphabet_war(fight):
	(L, R) = (0, 0)
	for e in fight:
		if e == 'w':
			L += 4
		if e == 'p':
			L += 3
		if e == 'b':
			L += 2
		if e == 's':
			L += 1
		if e == 'm':
			R += 4
		if e == 'q':
			R += 3
		if e == 'd':
			R += 2
		if e == 'z':
			R += 1
	if L > R:
		return 'Left side wins!'
	if R > L:
		return 'Right side wins!'
	return "Let's fight again!"


def alphabet_war(fight):
	left_letters = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right_letters = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	sum_left = 0
	sum_right = 0
	fight = fight.lower()
	for char in fight:
		if char in left_letters:
			number1 = left_letters[char]
			sum_left += number1
		elif char in right_letters:
			number2 = right_letters[char]
			sum_right += number2
	if sum_left > sum_right:
		return 'Left side wins!'
	elif sum_right > sum_left:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	rules = {'w': 4, 'p': 3, 'b': 2, 's': 1, 'm': -4, 'q': -3, 'd': -2, 'z': -1}
	fight = list([i for i in [x for x in fight] if i in 'wpbsmqdz'])
	res = sum([rules.get(x) for x in fight])
	if res == 0:
		return "Let's fight again!"
	return 'Right side wins!' if res < 0 else 'Left side wins!'


def alphabet_war(fight):
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	total1 = 0
	total2 = 0
	for i in range(len(fight)):
		for j1 in left:
			if fight[i] == j1:
				total1 += left[j1]
		for m1 in right:
			if fight[i] == m1:
				total2 += right[m1]
	if total1 > total2:
		return 'Left side wins!'
	elif total1 == total2:
		return "Let's fight again!"
	elif total1 < total2:
		return 'Right side wins!'


def alphabet_war(fight):
	left_score = 0
	right_score = 0
	for l in list(fight):
		if l == 'w':
			left_score += 4
		elif l == 'p':
			left_score += 3
		elif l == 'b':
			left_score += 2
		elif l == 's':
			left_score += 1
		elif l == 'm':
			right_score += 4
		elif l == 'q':
			right_score += 3
		elif l == 'd':
			right_score += 2
		elif l == 'z':
			right_score += 1
	if left_score > right_score:
		return 'Left side wins!'
	elif left_score < right_score:
		return 'Right side wins!'
	elif right_score == left_score:
		return "Let's fight again!"


def alphabet_war(fight):
	leftDict = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	rightDict = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	totalSum = sum((leftDict[x] if x in leftDict else -rightDict[x] if x in rightDict else 0 for x in fight))
	return "Let's fight again!" if totalSum == 0 else 'Left side wins!' if totalSum > 0 else 'Right side wins!'


import string

def alphabet_war(fight):
	leftside = [x for x in fight.lower() if x in 'wpbs']
	rightside = [x for x in fight.lower() if x in 'mqdz']
	rl = sum((int(x) for x in ''.join(leftside).translate(str.maketrans('wpbs', '4321'))))
	rr = sum((int(x) for x in ''.join(rightside).translate(str.maketrans('mqdz', '4321'))))
	if rl == rr:
		return "Let's fight again!"
	elif rl > rr:
		return 'Left side wins!'
	else:
		return 'Right side wins!'


def alphabet_war(fight):
	(r, l) = (0, 0)
	c = 1
	for i in 'sbpw':
		l += fight.count(i) * c
		c += 1
	c = 1
	for i in 'zdqm':
		r += fight.count(i) * c
		c += 1
	if l > r:
		return 'Left side wins!'
	elif r > l:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left = '0sbpw'
	right = '0zdqm'
	l = sum((left.index(i) for i in fight if i in left))
	r = sum((right.index(i) for i in fight if i in right))
	if r == l:
		return "Let's fight again!"
	if l > r:
		return 'Left side wins!'
	return 'Right side wins!'


def alphabet_war(fight):
	l_scores = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	r_scores = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	l = 0
	r = 0
	for ch in fight:
		l += l_scores[ch] if ch in list(l_scores.keys()) else 0
		r += r_scores[ch] if ch in list(r_scores.keys()) else 0
	return 'Left side wins!' if l > r else 'Right side wins!' if r > l else "Let's fight again!"


def alphabet_war(fight):
	left_power = 0
	right_power = 0
	fight = list(fight)
	for letter in fight:
		if letter == 'z':
			right_power += 1
		elif letter == 'd':
			right_power += 2
		elif letter == 'q':
			right_power += 3
		elif letter == 'm':
			right_power += 4
		elif letter == 's':
			left_power += 1
		elif letter == 'b':
			left_power += 2
		elif letter == 'p':
			left_power += 3
		elif letter == 'w':
			left_power += 4
		else:
			continue
	if left_power > right_power:
		return 'Left side wins!'
	elif right_power > left_power:
		return 'Right side wins!'
	elif right_power == left_power:
		return "Let's fight again!"


def alphabet_war(fight):
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left_power = 0
	right_power = 0
	for fighter in fight:
		if fighter in left:
			left_power += left.get(fighter)
		if fighter in right:
			right_power += right.get(fighter)
	if left_power > right_power:
		return 'Left side wins!'
	if left_power < right_power:
		return 'Right side wins!'
	return "Let's fight again!"


def alphabet_war(fight):
	l_letters = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	r_letters = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	l_sum = 0
	r_sum = 0
	for letter in fight:
		for (key, value) in l_letters.items():
			if key == letter:
				l_sum += value
		for (key, value) in r_letters.items():
			if key == letter:
				r_sum += value
	if r_sum > l_sum:
		return 'Right side wins!'
	elif r_sum < l_sum:
		return 'Left side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left = {c: i for (i, c) in enumerate('sbpw', 1)}
	right = {c: i for (i, c) in enumerate('zdqm', 1)}
	battle = sum((left.get(c, 0) - right.get(c, 0) for c in fight.lower()))
	if battle > 0:
		return 'Left side wins!'
	elif battle < 0:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	s = 0
	for c in fight:
		if c in 'mqdzsbpw':
			s += 'mqdz_sbpw'.index(c) - 4
	if s > 0:
		return 'Left side wins!'
	elif s == 0:
		return "Let's fight again!"
	else:
		return 'Right side wins!'


def alphabet_war(fight):
	count = 0
	left_power = dict(w=4, p=3, b=2, s=1)
	right_power = dict(m=4, q=3, d=2, z=1)
	for l in fight:
		if l in left_power:
			count += left_power[l]
		elif l in right_power:
			count -= right_power[l]
	if count < 0:
		return 'Right side wins!'
	if count > 0:
		return 'Left side wins!'
	elif count == 0:
		return "Let's fight again!"


def alphabet_war(fight):
	lef = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	rig = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	lp = 0
	rp = 0
	for x in fight:
		if x in lef:
			lp += lef[x]
		if x in rig:
			rp += rig[x]
	return 'Right side wins!' if rp > lp else 'Left side wins!' if lp > rp else "Let's fight again!"


d1 = {'w': 4, 'p': 3, 'b': 2, 's': 1}
d2 = {'m': 4, 'q': 3, 'd': 2, 'z': 1}

def alphabet_war(fight):
	r = 0
	l = 0
	for i in fight:
		if i in d1.keys():
			l += d1[i]
		elif i in d2.keys():
			r += d2[i]
	return 'Right side wins!' if r > l else 'Left side wins!' if l > r else "Let's fight again!"


def alphabet_war(fight):
	left_side = []
	right_side = []
	for elem in fight:
		if elem == 'w':
			left_side.append(4)
		elif elem == 'p':
			left_side.append(3)
		elif elem == 'b':
			left_side.append(2)
		elif elem == 's':
			left_side.append(1)
		elif elem == 'm':
			right_side.append(4)
		elif elem == 'q':
			right_side.append(3)
		elif elem == 'd':
			right_side.append(2)
		elif elem == 'z':
			right_side.append(1)
	print(right_side)
	if sum(left_side) > sum(right_side):
		return 'Left side wins!'
	elif sum(left_side) < sum(right_side):
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left = 0
	right = 0
	for x in fight:
		if x in 'wpbs':
			p1 = {'w': 4, 'p': 3, 'b': 2, 's': 1}
			left += p1.get(x)
		elif x in 'mqdz':
			p2 = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
			right += p2.get(x)
	if left != right:
		return 'Left side wins!' if left > right else 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left_side = 0
	right_side = 0
	for elem in fight:
		if elem in left.keys():
			left_side = left_side + left[elem]
		elif elem in right.keys():
			right_side = right_side + right[elem]
	return 'Left side wins!' if left_side > right_side else 'Right side wins!' if left_side < right_side else "Let's fight again!"


def alphabet_war(fight):
	res = 0
	right = ' zdqm'
	left = ' sbpw'
	for i in fight:
		try:
			res -= left.index(i)
		except:
			try:
				res += right.index(i)
			except:
				pass
	if res > 0:
		return 'Right side wins!'
	if res == 0:
		return "Let's fight again!"
	return 'Left side wins!'


def alphabet_war(fight):
	left_side = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right_side = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left_side_total = 0
	right_side_total = 0
	for eachletter in fight:
		if eachletter in left_side.keys():
			left_side_total = left_side_total + left_side[eachletter]
		elif eachletter in right_side.keys():
			right_side_total = right_side_total + right_side[eachletter]
	if left_side_total > right_side_total:
		return 'Left side wins!'
	elif right_side_total > left_side_total:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	power = 0
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	for i in fight:
		if i in left:
			power += left[i]
		elif i in right:
			power -= right[i]
	if power < 0:
		return 'Right side wins!'
	if power > 0:
		return 'Left side wins!'
	elif power == 0:
		return "Let's fight again!"


def alphabet_war(fight):
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left_score = sum((left[d] for d in fight if d in left))
	right_score = sum((right[d] for d in fight if d in right))
	if left_score > right_score:
		return 'Left side wins!'
	elif left_score < right_score:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(t):
	(a, b) = (0, 0)
	(A, B) = (['s', 'b', 'p', 'w'], ['z', 'd', 'q', 'm'])
	for i in t:
		if i in A:
			a += A.index(i) + 1
		elif i in B:
			b += B.index(i) + 1
	return f"{['Right', 'Left'][a > b]} side wins!" if a != b else "Let's fight again!"


def alphabet_war(fight):
	lres = 0
	rres = 0
	ldicc = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	rdicc = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	for elem in fight:
		if elem in ldicc:
			lres = lres + ldicc[elem]
		elif elem in rdicc:
			rres = rres + rdicc[elem]
	if rres > lres:
		return 'Right side wins!'
	elif lres > rres:
		return 'Left side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight, n=0):
	alpha = {'s': 1, 'z': -1, 'b': 2, 'd': -2, 'p': 3, 'q': -3, 'w': 4, 'm': -4}
	for c in fight:
		n += alpha.get(c, 0)
	return ('Left' if n > 0 else 'Right') + ' side wins!' if n else "Let's fight again!"


def alphabet_war(fight):
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	left_count = 0
	right_count = 0
	(right, left) = (right.items(), left.items())
	for (right_letter, left_letter) in zip(right, left):
		for letter in fight:
			if letter == right_letter[0]:
				right_count += right_letter[1]
			if letter == left_letter[0]:
				left_count += left_letter[1]
	if left_count > right_count:
		return 'Left side wins!'
	elif right_count > left_count:
		return 'Right side wins!'
	elif right_count == left_count:
		return "Let's fight again!"


def alphabet_war(fight):
	powers = {'w': 4, 'p': 3, 'b': 2, 's': 1, 'm': -4, 'q': -3, 'd': -2, 'z': -1}
	points = sum((powers.get(f, 0) for f in fight))
	if points > 0:
		return 'Left side wins!'
	elif points == 0:
		return "Let's fight again!"
	return 'Right side wins!'


def alphabet_war(fight):
	left_alp = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right_alp = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left_score = 0
	right_score = 0
	for i in left_alp:
		left_score += fight.count(i) * left_alp[i]
	for i in right_alp:
		right_score += fight.count(i) * right_alp[i]
	return 'Right side wins!' if right_score > left_score else "Let's fight again!" if right_score == left_score else 'Left side wins!'


def alphabet_war(fight):
	winner = sum((' zdqm'.index(x) for x in fight if x in 'zdqm')) - sum((' sbpw'.index(x) for x in fight if x in 'sbpw'))
	return 'Left side wins!' if winner < 0 else 'Right side wins!' if winner > 0 else "Let's fight again!"


import unittest
RIGHT_SIDE_WINS = 'Right side wins!'
LEFT_SIDE_WINS = 'Left side wins!'
FIGHT_AGAIN = "Let's fight again!"
LEFT_LETTERS = {'w': 4, 'p': 3, 'b': 2, 's': 1}
RIGHT_LETTERS = {'m': 4, 'q': 3, 'd': 2, 'z': 1}

def alphabet_war(fight):
	left = []
	right = []
	for ele in fight:
		if ele in LEFT_LETTERS:
			left.append(LEFT_LETTERS[ele])
		elif ele in RIGHT_LETTERS:
			right.append(RIGHT_LETTERS[ele])
	if sum(left) == sum(right):
		return FIGHT_AGAIN
	else:
		return LEFT_SIDE_WINS if sum(left) > sum(right) else RIGHT_SIDE_WINS

class TestAlphabetWar(unittest.TestCase):

	def test_alphabet_war_on_right_side_wins(self):
		fight = 'z'
		actual = alphabet_war(fight)
		self.assertEqual(actual, RIGHT_SIDE_WINS)

	def test_alphabet_war_on_left_side_wins(self):
		fight = 'wq'
		actual = alphabet_war(fight)
		self.assertEqual(actual, LEFT_SIDE_WINS)

	def test_alphabet_war_on_fight_again(self):
		fight = 'zdqmwpbs'
		actual = alphabet_war(fight)
		self.assertEqual(actual, FIGHT_AGAIN)


def alphabet_war(fight):
	left = {'w': -4, 'p': -3, 'b': -2, 's': -1}
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left.update(right)
	points = sum([left[x] for x in fight if x in left])
	win = 'Left side wins!' if points < 0 else "Let's fight again!" if points == 0 else 'Right side wins!'
	return win


def alphabet_war(fight):
	dl = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	dr = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	lwork = 0
	rwork = 0
	for x in fight:
		lwork += dl.get(x, 0)
		rwork += dr.get(x, 0)
	if lwork == rwork:
		return "Let's fight again!"
	elif lwork > rwork:
		return 'Left side wins!'
	else:
		return 'Right side wins!'


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

def alphabet_war(fight):
	l = r = 0
	for i in fight:
		if i in 'wpbs':
			l += db[i]
		elif i in 'mqdz':
			r += db[i]
	return 'Left side wins!' if l > r else 'Right side wins!' if r > l else "Let's fight again!"


def alphabet_war(fight):
	chars = list(fight)
	left = 4 * chars.count('w') + 3 * chars.count('p') + 2 * chars.count('b') + 1 * chars.count('s')
	right = 4 * chars.count('m') + 3 * chars.count('q') + 2 * chars.count('d') + 1 * chars.count('z')
	if left > right:
		return 'Left side wins!'
	elif left < right:
		return 'Right side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	(r, r_c) = ('zdqm', 0)
	(l, l_c) = ('sbpw', 0)
	for i in fight:
		if i in r:
			r_c += r.index(i) + 1
		elif i in l:
			l_c += l.index(i) + 1
	if r_c > l_c:
		return 'Right side wins!'
	elif l_c > r_c:
		return 'Left side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left_scores = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	right_scores = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left_score = 0
	right_score = 0
	for char in fight:
		if char in left_scores.keys():
			left_score += left_scores[char]
		elif char in right_scores.keys():
			right_score += right_scores[char]
	if right_score > left_score:
		return 'Right side wins!'
	elif left_score > right_score:
		return 'Left side wins!'
	else:
		return "Let's fight again!"


def alphabet_war(fight):
	left = ['w', 'p', 'b', 's']
	right = ['m', 'q', 'd', 'z']
	powers = {'w': 4, 'p': 3, 'b': 2, 's': 1, 'm': 4, 'q': 3, 'd': 2, 'z': 1}
	phrase = list(fight)
	left_total = 0
	right_total = 0
	for letter in phrase:
		if letter in right:
			right_total = right_total + powers[letter]
		if letter in left:
			left_total = left_total + powers[letter]
	if left_total > right_total:
		return 'Left side wins!'
	if right_total > left_total:
		return 'Right side wins!'
	return "Let's fight again!"


def alphabet_war(fight):
	if fight == '':
		return "Let's fight again!"
	left_side = {'s': 1, 'b': 2, 'p': 3, 'w': 4}
	right_side = {'z': 1, 'd': 2, 'q': 3, 'm': 4}
	left_side_count = 0
	right_side_count = 0
	for letter in fight:
		if letter in left_side:
			left_side_count += left_side[letter]
		elif letter in right_side:
			right_side_count += right_side[letter]
	if left_side_count > right_side_count:
		answer = 'Left side wins!'
	elif right_side_count > left_side_count:
		answer = 'Right side wins!'
	else:
		answer = "Let's fight again!"
	return answer


def alphabet_war(fight):
	versus = {'w': 4, 'p': 3, 'b': 2, 's': 1, 'm': -4, 'q': -3, 'd': -2, 'z': -1}
	score = []
	for x in fight:
		for (key, value) in versus.items():
			if x == key:
				score.append(value)
	if sum(score) > 0:
		return 'Left side wins!'
	if sum(score) < 0:
		return 'Right side wins!'
	return "Let's fight again!"
print(alphabet_war('zzzzs'))


def alphabet_war(fight):
	(lefts, rights) = ('wpbs', 'mqdz')
	score_right = sum([4 - rights.find(x) for x in fight if x in rights])
	score_left = sum([4 - lefts.find(x) for x in fight if x in lefts])
	return ["Let's fight again!", ['Right side wins!', 'Left side wins!'][score_left > score_right]][score_right != score_left]


def alphabet_war(fight):
	right = {'m': 4, 'q': 3, 'd': 2, 'z': 1}
	left = {'w': 4, 'p': 3, 'b': 2, 's': 1}
	rarr = []
	larr = []
	for s in fight:
		if s in 'mqdz':
			rarr.append(right.get(s))
		elif s in 'wpbs':
			larr.append(left.get(s))
	return 'Left side wins!' if sum(larr) > sum(rarr) else 'Right side wins!' if sum(rarr) > sum(larr) else "Let's fight again!"