Skip to content

Instantly share code, notes, and snippets.

@SahilKadam
Created November 15, 2016 17:43
Show Gist options
  • Save SahilKadam/a3217799400e149f8af1720e4c98cbc1 to your computer and use it in GitHub Desktop.
Save SahilKadam/a3217799400e149f8af1720e4c98cbc1 to your computer and use it in GitHub Desktop.
Strings: Making Anagrams
def number_needed(a, b):
count = 0
if len(a) >= len(b):
for i in range(len(b)):
if b[i] in a:
temp = list(a)
temp.remove(b[i])
a = "".join(temp)
else:
count += 1
return (len(a) + count)
else:
for i in range(len(a)):
if a[i] in b:
temp = list(b)
temp.remove(a[i])
b = "".join(temp)
else:
count += 1
return (len(b) + count)
a = input().strip()
b = input().strip()
print(number_needed(a, b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment