Given an array (arr) as an argument complete the function `countSmileys` that should return the total number of smiling faces.  

Rules for a smiling face:
- Each smiley face must contain a valid pair of eyes. Eyes can be marked as `:` or `;`
- A smiley face can have a nose but it does not have to. Valid characters for a nose are `-` or `~`
- Every smiling face must have a smiling mouth that should be marked with either `)` or `D`

No additional characters are allowed except for those mentioned.  

**Valid smiley face examples:** `:) :D ;-D :~)`  
**Invalid smiley faces:**  `;( :> :} :]`

## Example

```
countSmileys([':)', ';(', ';}', ':-D']);       // should return 2;
countSmileys([';D', ':-(', ':-)', ';~)']);     // should return 3;
countSmileys([';]', ':[', ';*', ':$', ';-D']); // should return 1;
```

## Note

In case of an empty array return 0. You will not be tested with invalid input (input will always be an array). Order of the face (eyes, nose, mouth) elements will always be the same.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def count_smileys(arr):
	

Solutions:
from re import findall

def count_smileys(arr):
	return len(list(findall('[:;][-~]?[)D]', ' '.join(arr))))


def count_smileys(arr):
	eyes = [':', ';']
	noses = ['', '-', '~']
	mouths = [')', 'D']
	count = 0
	for eye in eyes:
		for nose in noses:
			for mouth in mouths:
				face = eye + nose + mouth
				count += arr.count(face)
	return count


import re

def count_smileys(arr):
	return sum((1 for s in arr if re.match('\\A[:;][-~]?[)D]\\Z', s)))


def count_smileys(arr):
	import re
	smiley = re.compile('[:;][-~]?[)D]')
	return sum((bool(re.match(smiley, el)) for el in arr))


def count_smileys(arr):
	count = 0
	if not arr:
		return 0
	smileys = [':)', ';)', ':~)', ';~)', ':-)', ';-)', ':D', ';D', ':~D', ';~D', ':-D', ';-D']
	for i in arr:
		if i in smileys:
			count += 1
	return count


def count_smileys(arr):
	total = 0
	eyes = ':;'
	nose = '-~'
	mouth = ')D'
	for char in arr:
		if len(char) == 3:
			if char[0] in eyes and char[1] in nose and (char[2] in mouth):
				total += 1
		elif len(char) == 2:
			if char[0] in eyes and char[1] in mouth:
				total += 1
	return total


def count_smileys(arr):
	smiles = set([a + b + c for a in ':;' for b in ['', '-', '~'] for c in ')D'])
	return len([1 for s in arr if s in smiles])


valid = ':) :D :-) :-D :~) :~D ;) ;D ;-) ;-D ;~) ;~D'.split()

def count_smileys(arr):
	return sum((face in valid for face in arr))


import re

def count_smileys(arr):
	count = 0
	for i in arr:
		p = re.compile('^[:;][-~]*[)D]')
		if p.match(i):
			count += 1
	return count


def count_smileys(arr):
	return len(list(filter(lambda x: x in [':D', ':~D', ':-D', ';D', ';~D', ';-D', ':)', ':~)', ':-)', ';)', ';~)', ';-)'], arr)))