In this Kata, we are going to see how a Hash (or Map or dict) can be used to keep track of characters in a string. 

Consider two strings `"aabcdefg"` and `"fbd"`. How many characters do we have to remove from the first string to get the second string?  Although not the only way to solve this, we could create a Hash of counts for each string and see which character counts are different. That should get us close to the answer. I will leave the rest to you. 

For this example, `solve("aabcdefg","fbd") = 5`. Also, `solve("xyz","yxxz") = 0`, because we cannot get second string from the first since the second string is longer.

More examples in the test cases.

Good luck!

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def solve(a,b):
	

Solutions:
from collections import Counter

def solve(a, b):
	return 0 if Counter(b) - Counter(a) else len(a) - len(b)


def solve(a, b):
	for x in set(b):
		if a.count(x) >= b.count(x):
			continue
		else:
			return 0
	return len(a) - len(b)


def solve(a, b):
	print((a, b))
	if sorted(a) == sorted(b) or set(list(a)) == set(list(b)):
		return 0
	for x in b:
		for x in a:
			if a.count(x) < b.count(x):
				return 0
	else:
		return len(a) - len(b)


def solve(a, b):
	a = list(a)
	try:
		for c in b:
			a.pop(a.index(c))
		return len(a)
	except:
		return 0


def solve(a, b):
	for char in b:
		return 0 if b.count(char) > a.count(char) or len(b) >= len(a) else len(a) - len(b)


from collections import Counter

def solve(a, b):
	return sum((Counter(a) - Counter(b)).values()) if Counter(b) - Counter(a) == {} else 0


from collections import Counter

def solve(a, b):
	(c_diff, c_b) = (Counter(a), Counter(b))
	c_diff.subtract(c_b)
	result = 0
	for (k, v) in c_diff.items():
		if v >= 0:
			result += v
		else:
			return 0
	return result


from collections import Counter

def solve(a, b):
	aa = Counter(a)
	bb = Counter(b)
	for (k, v) in list(bb.items()):
		diff = aa[k] - v
		aa[k] -= v
		if diff < 0:
			return 0
	return sum(aa.values())


solve = lambda a, b, c=__import__('collections').Counter: not c(b) - c(a) and len(a) - len(b)


from collections import Counter as C

def solve(Q, S):
	(Q, S) = (C(Q), C(S))
	if all((V in Q and S[V] <= Q[V] for V in S)):
		return sum((Q[V] - (S[V] if V in S else 0) for V in Q))
	return 0