You are on page 1of 1

a = raw_input("Enter string a: ")

b = raw_input("Enter string b: ")


#print "String a is: "+a
#print "String b is: "+b
lena = len(a)
lenb = len(b)
#print lena,lenb
ela = set(a)
elb = set(b)
#print ela,elb
cnta = {}
cntb = {}
for s in ela:
cnta[s] = a.count(s)
for s in elb:
cntb[s] = b.count(s)
print cnta,cntb
commonel = ela.intersection(elb)
unionel = ela.union(elb)
noncommonel = unionel.difference(commonel)
print commonel,noncommonel
commondel = 0
for c in commonel:
commondel = commondel + abs(cnta[c]-cntb[c])
noncommondel = 0
for nc in noncommonel:
if nc in ela:
noncommondel = noncommondel + cnta[nc]
elif nc in elb:
noncommondel = noncommondel + cntb[nc]
print commondel,noncommondel
totaldel = commondel+noncommondel
print totaldel

You might also like