Roma is programmer and he likes memes about IT,  
Maxim is chemist and he likes memes about chemistry,  
Danik is designer and he likes memes about design,  
and Vlad likes all other memes.

___

You will be given a meme (string), and your task is to identify its category, and send it to the right receiver: `IT - 'Roma'`, `chemistry - 'Maxim'`, `design - 'Danik'`, or `other - 'Vlad'`.

IT meme has letters `b, u, g`.  
Chemistry meme has letters `b, o, o, m`.  
Design meme has letters `e, d, i, t, s`.  
If there is more than 1 possible answer, the earliest match should be chosen.

**Note:** letters are case-insensetive and should come in the order specified above.

___

## Examples:

(Matching letters are surrounded by curly braces for readability.)

```
this is programmer meme {b}ecause it has b{ug}
this is also program{bu}r meme {g}ecause it has needed key word
this is {ed}s{i}gner meme cause i{t} ha{s} key word

this could {b}e chemistry meme b{u}t our{g}Gey word 'boom' is too late
    instead of
this could {b}e chemistry meme but {o}ur gey w{o}rd 'boo{m}' is too late
```

Difficulty: EASY
Starter code: def memesorting(meme):
	

Solutions:
import re
from itertools import accumulate
patterns = [(re.compile('.*'.join('bug'), flags=re.I), 'Roma'), (re.compile('.*'.join('boom'), flags=re.I), 'Maxim'), (re.compile('.*'.join('edits'), flags=re.I), 'Danik')]

def memesorting(meme):
	return next((who for m in accumulate(meme) for (pattern, who) in patterns if pattern.search(m)), 'Vlad')


def memesorting(meme):
	typ = ('Roma', 'Maxim', 'Danik')
	what = ('bug', 'boom', 'edits')
	bug_boom_edits = [list(l[::-1]) for l in what]
	for c in meme.lower():
		for (i, l) in enumerate(bug_boom_edits):
			if l[-1] == c:
				l.pop()
			if not l:
				return typ[i]
	else:
		return 'Vlad'


import re

def memesorting(s):
	f = lambda w: re.search('{}'.format('.*?'.join(w)), s, re.IGNORECASE)
	a = [[m.span()[1], i] for (i, m) in enumerate((f(x) for x in ['bug', 'boom', 'edits'])) if m]
	return ['Roma', 'Maxim', 'Danik'][min(a)[1]] if a else 'Vlad'


def memesorting(meme):
	keys = {'bug': '', 'boom': '', 'edits': ''}
	for (i, l) in enumerate(meme.lower()):
		for (key, value) in {'bug': 'Roma', 'boom': 'Maxim', 'edits': 'Danik'}.items():
			if l == key[len(keys[key])]:
				keys[key] += l
				if keys[key] == key:
					return value
	return 'Vlad'


def memesorting(s):
	(order_p, p, ini_p, order_c, c, int_c, order_d, d, int_d) = ({0: 'b', 1: 'u', 2: 'g'}, '', 0, {0: 'b', 1: 'o', 2: 'o', 3: 'm'}, '', 0, {0: 'e', 1: 'd', 2: 'i', 3: 't', 4: 's'}, '', 0)
	for i in s.lower():
		if i == order_p[ini_p]:
			p += i
			ini_p += 1
		if i == order_c[int_c]:
			c += i
			int_c += 1
		if i == order_d[int_d]:
			d += i
			int_d += 1
		for k in range(3):
			if ['bug', 'boom', 'edits'][k] == [p, c, d][k]:
				return ['Roma', 'Maxim', 'Danik'][k]
	return 'Vlad'


def memesorting(meme):
	bug = 'bug'
	boom = 'boom'
	edits = 'edits'
	for i in meme.lower():
		if i == bug[0]:
			bug = bug[1:]
			if len(bug) == 0:
				return 'Roma'
		if i == boom[0]:
			boom = boom[1:]
			if len(boom) == 0:
				return 'Maxim'
		if i == edits[0]:
			edits = edits[1:]
			if len(edits) == 0:
				return 'Danik'
	return 'Vlad'


def memesorting(meme):
	(bug, boom, edits) = (['b', 'u', 'g'], ['b', 'o', 'o', 'm'], ['e', 'd', 'i', 't', 's'])
	for ch in meme.lower():
		if ch == bug[0]:
			bug.pop(0)
			if not bug:
				return 'Roma'
		if ch == boom[0]:
			boom.pop(0)
			if not boom:
				return 'Maxim'
		if ch == edits[0]:
			edits.pop(0)
			if not edits:
				return 'Danik'
	return 'Vlad'


def memesorting(meme):
	print(meme)
	targets = [['bug', 0, 'Roma'], ['boom', 0, 'Maxim'], ['edits', 0, 'Danik']]
	for char in meme:
		for target in targets:
			if char.lower() == target[0][target[1]]:
				target[1] += 1
				if target[1] == len(target[0]):
					return target[2]
	return 'Vlad'


import re
PATTERNS = (('Roma', '.*?'.join('bug')), ('Maxim', '.*?'.join('boom')), ('Danik', '.*?'.join('edits')))

def memesorting(meme):
	result = (float('inf'), 'Vlad')
	for (name, p) in PATTERNS:
		res = re.search(p, meme, re.IGNORECASE)
		if res:
			result = min(result, (res.span()[1], name))
	return result[1]


import regex as re

def memesorting(meme):
	meme = meme.lower()
	print(meme)
	check = []
	bug = re.search('b.*?u.*?g', meme)
	if bug is not None:
		check.append(bug)
	boom = re.search('b.*?o.*?o.*?m', meme)
	if boom is not None:
		check.append(boom)
	edits = re.search('e.*?d.*?i.*?t.*?s', meme)
	if edits is not None:
		check.append(edits)
	if check != []:
		first = min(check, key=lambda match: match.span()[1])
	else:
		return 'Vlad'
	if first.group()[-1] == 'g':
		return 'Roma'
	if first.group()[-1] == 's':
		return 'Danik'
	else:
		return 'Maxim'
	return