We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def number_needed(a, b):
r=ca=cb=0
for i in set(a):
ca=a.count(i)
if i in b:
cb=b.count(i)
r+= abs(ca - cb)
else:
r +=ca
for i in set(b):
cb=b.count(i)
if i not in a:
r+= cb
return r
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
def number_needed(a, b): r=ca=cb=0 for i in set(a): ca=a.count(i) if i in b: cb=b.count(i) r+= abs(ca - cb) else: r +=ca for i in set(b): cb=b.count(i) if i not in a: r+= cb return r