Your friend has invited you to a party, and tells you to meet them in the line to get in. The one problem is it's a masked party. Everyone in line is wearing a colored mask, including your friend. Find which people in line could be your friend.

Your friend has told you that he will be wearing a `RED` mask, and has **TWO** other friends with him, both wearing `BLUE` masks.

Input to the function will be an array of strings, each representing a colored mask. For example:
```python
line = ['blue','blue','red','red','blue','green']
```

The output of the function should be the number of people who could possibly be your friend.
```python
friend_find(['blue','blue','red','red','blue','green','chipmunk'])  # return 1
```

Source: codewars | Difficulty: EASY
Tags: Data structures

Ad-hoc

Starter code: def friend_find(line):
	

Solutions:
def redWith2Blues(i, line):
	return any((line[i - 2 + x:i + 1 + x].count('blue') == 2 for x in range(3)))

def friend_find(line):
	return sum((p == 'red' and redWith2Blues(i, line) for (i, p) in enumerate(line)))


def friend_find(line):
	N = len(line)
	A = lambda i: line[i] == 'red' and B(i)
	B = lambda i: C(i) or D(i) or E(i)
	C = lambda i: i < N - 2 and line[i + 1] == line[i + 2] == 'blue'
	D = lambda i: 0 < i < N - 1 and line[i - 1] == line[i + 1] == 'blue'
	E = lambda i: 1 < i and line[i - 2] == line[i - 1] == 'blue'
	return sum(map(A, range(N)))


friend_find = lambda arr: sum([1 for i in range(len(arr)) if arr[i] == 'red' if i > 1 and arr[i - 1] == 'blue' and (arr[i - 2] == 'blue') or (i > 0 and i < len(arr) - 1 and (arr[i - 1] == 'blue') and (arr[i + 1] == 'blue')) or (i < len(arr) - 2 and arr[i + 1] == 'blue' and (arr[i + 2] == 'blue'))])


import re

def friend_find(line):
	s = ' '.join(line)
	return len(re.findall('\\bblue blue red\\b|\\bblue red (?=blue\\b)|\\bred (?=blue blue\\b)', s))


friend_find = lambda L: sum((p == 'red' and any((L[x:x + 3].count('blue') == 2 for x in range(max(0, i - 2), i + 1))) for (i, p) in enumerate(L)))


def friend_find(line):
	s = ''.join([[c[0], 'y'][c not in ['red', 'green', 'blue']] for c in line])
	r = ''
	c = 0
	for i in s:
		if len(r) < 3:
			r += i
		else:
			r = (r + i)[1:]
		if [r.count('r'), r.count('b')] == [1, 2]:
			c += 1
			n = ''
			for i in r:
				if i == 'r':
					n += 'x'
				else:
					n += i
			r = n[:]
	return c


def friend_find(line):
	possible_combo = (['blue', 'blue', 'red'], ['blue', 'red', 'blue'], ['red', 'blue', 'blue'])
	return len({i + line[i:i + 3].index('red') for i in range(len(line)) if line[i:i + 3] in possible_combo})


from itertools import permutations

def friend_find(line):
	p = list(set(permutations(['red', 'blue', 'blue'], 3)))
	f = i = 0
	while i < len(line):
		x = tuple(line[i:i + 3])
		if x in p:
			f += 1
			i += x.index('red')
		i += 1
	return f


def friend_find(line):
	s = 0
	for i in range(0, len(line) - 2):
		(f1, f2, f3) = (line[i], line[i + 1], line[i + 2])
		if [f1, f2, f3] == ['red', 'blue', 'blue']:
			s += 1
		elif [f1, f2, f3] == ['blue', 'red', 'blue']:
			s += 1
			line[i + 1] = ''
		elif [f1, f2, f3] == ['blue', 'blue', 'red']:
			s += 1
			line[i + 2] = ''
	return s