-
-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathAnagrams.py
More file actions
33 lines (25 loc) · 564 Bytes
/
Anagrams.py
File metadata and controls
33 lines (25 loc) · 564 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
print('ANAGRAM')
from collections import *
a=Counter(input())
b=Counter(input())
c=a-b
d=b-a
e=c+d
#print(a,b,c,d,e)
print(len(list(e.elements())))
or
import math
def number_needed(a, b):
aString = [0]*26
for ch in a:
aString[ord(ch)-97] += 1
bString = [0]*26
for ch in b:
bString[ord(ch)-97] += 1
deletions = 0
for i in range(len(aString)):
deletions += math.fabs(aString[i]-bString[i])
print(aString,bString,deletions)
a = input().strip()
b = input().strip()
print(number_needed(a, b))