Complete the function that determines the score of a hand in the card game [Blackjack](https://en.wikipedia.org/wiki/Blackjack) (aka 21).

The function receives an array of strings that represent each card in the hand (`"2"`, `"3",` ..., `"10"`, `"J"`, `"Q"`, `"K"` or `"A"`) and should return the score of the hand (integer).

~~~if:c
Note: in C the function receives a character array with the card `10` represented by the character `T`.
~~~


### Scoring rules:

Number cards count as their face value (2 through 10). Jack, Queen and King count as 10. An Ace can be counted as either 1 or 11.

Return the highest score of the cards that is less than or equal to 21. If there is no score less than or equal to 21 return the smallest score more than 21.


## Examples

```
["A"]                           ==>  11
["A", "J"]                      ==>  21
["A", "10", "A"]                ==>  12
["5", "3", "7"]                 ==>  15
["5", "4", "3", "2", "A", "K"]  ==>  25
```

Difficulty: EASY
Tags: Game theory

Starter code:
def score_hand(cards):
	

Solutions:
def score_hand(a):
	n = sum((11 if x == 'A' else 10 if x in 'JQK' else int(x) for x in a))
	for _ in range(a.count('A')):
		if n > 21:
			n -= 10
	return n


def score_hand(cards):
	total = 0
	number_of_aces = 0
	for i in cards:
		if i == 'A':
			total += 1
			number_of_aces += 1
		elif i == 'J' or i == 'Q' or i == 'K':
			total += 10
		else:
			total += int(i)
	if total <= 11 and number_of_aces >= 1:
		total += 10
	return total


def score_hand(cards):
	s = sum((c == 'A' or (c.isdigit() and int(c)) or 10 for c in cards))
	n = cards.count('A')
	return s + 10 * (n and s < 12)


def score_hand(li):
	(s, A) = (sum((int(i) if i.isdigit() else 10 for i in li if i != 'A')), li.count('A'))
	for i in range(A):
		s += [1, [11, 1][bool(s + 11 == 21 and i + 1 != A)]][s + 11 <= 21]
	return s


def score_hand(cards):
	aces = cards.count('A')
	score = sum((int(card) if card.isdigit() else 10 for card in cards)) + aces
	if score > 21:
		for _ in range(aces):
			score -= 10
			if score <= 21:
				break
	return score


def score_hand(cards):
	aces = [i for i in cards if i == 'A']
	cards = list(filter(lambda x: x is not 'A', cards))
	cards.extend(aces)
	total = 0
	for (i, card) in enumerate(cards):
		if card in ['J', 'Q', 'K']:
			total += 10
		elif card is 'A':
			total += 11 if 11 <= 21 - total and ''.join(cards).rindex('A') == i else 1
		else:
			total += int(card)
	return total


class Jack_score(object):

	def __init__(self, cards):
		self.A = cards.count('A')
		self.score = sum([int([[e, '10'][e in 'JQK'], '11'][e == 'A']) for e in cards])

	def get_score(self):
		while self.A and self.score > 21:
			self.score -= 10
			self.A -= 1
		return self.score

def score_hand(c):
	return Jack_score(c).get_score()


def score_hand(cards):
	total = 0
	Ace = 0
	for str in cards:
		if str == '1':
			total += 1
		if str == '2':
			total += 2
		if str == '3':
			total += 3
		if str == '4':
			total += 4
		if str == '5':
			total += 5
		if str == '6':
			total += 6
		if str == '7':
			total += 7
		if str == '8':
			total += 8
		if str == '9':
			total += 9
		if str == '10' or str == 'J' or str == 'Q' or (str == 'K'):
			total += 10
		if str == 'A':
			Ace += 1
	if Ace == 1:
		if total < 11:
			total += 11
		else:
			total += 1
	if Ace > 1:
		for i in range(Ace):
			if total < 10:
				total += 11
			else:
				total += 1
	return total


def score_hand(cards):
	k = 0
	for (i, x) in enumerate(cards):
		if x.isdigit():
			k += int(x)
		elif x != 'A':
			k += 10
		else:
			k += 1
	if k + 10 > 21 and 'A' in cards:
		return k
	elif 'A' in cards and k + 10 <= 21:
		return k + 10
	return k


def score_hand(cards):
	summ = 0
	count_A = 0
	for symb in cards:
		if symb.isdigit():
			summ += int(symb)
		elif symb == 'A':
			count_A += 1
		else:
			summ += 10
	for i in range(count_A):
		summ += 11 * (count_A - i) if summ + 11 * (count_A - i) <= 21 else 1
	return summ