Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dict_adder(j_dict,j_char):
- """Adds an element to the dict in pos parameter 1
- from the character that is provided in pos parameter 2"""
- if j_dict.has_key(j_char):
- j_dict[j_char] += 1
- else:
- j_dict[j_char] = 1
- def number_needed(a, b):
- answer = 0
- a_set = set(a)
- b_set = set(b)
- a_dict, b_dict = {}, {}
- map(lambda x: dict_adder(a_dict,x), a)
- map(lambda x: dict_adder(b_dict,x), b)
- diff_set_a = a_set.difference(b_set)
- diff_set_b = b_set.difference(a_set)
- intersection_set_a = a_set.intersection(b_set)
- if diff_set_a is not None:
- answer += sum([ a_dict[j] for j in diff_set_a])
- if diff_set_b is not None:
- answer += sum([ b_dict[j] for j in diff_set_b])
- for j in intersection_set_a:
- if a_dict[j] > b_dict[j]:
- answer += a_dict[j] - b_dict[j]
- elif a_dict[j] < b_dict[j]:
- answer += b_dict[j] - a_dict[j]
- return answer
- a = raw_input().strip()
- b = raw_input().strip()
- print number_needed(a, b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement