Add some easy one

This commit is contained in:
2019-12-18 21:06:22 +01:00
parent 95b2aa6c2f
commit 1ac80708fc
6 changed files with 127 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
def verify_anagrams(first_word, second_word):
first_word = first_word.replace(" ", "").lower()
second_word = list(second_word.replace(" ", "").lower())
for letter in first_word:
if letter in second_word:
second_word.remove(letter)
else:
return False
return len(second_word) == 0
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
assert isinstance(verify_anagrams("a", 'z'), bool), "Boolean!"
assert verify_anagrams("Programming", "Gram Ring Mop") == True, "Gram of code"
assert verify_anagrams("Hello", "Ole Oh") == False, "Hello! Ole Oh!"
assert verify_anagrams("Kyoto", "Tokyo") == True, "The global warming crisis of 3002"