Created
November 15, 2016 17:43
-
-
Save SahilKadam/a3217799400e149f8af1720e4c98cbc1 to your computer and use it in GitHub Desktop.
Strings: Making Anagrams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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