Created
August 4, 2023 14:08
-
-
Save athursto/367cb90630ec93e53cb5fc5f67d04bcc to your computer and use it in GitHub Desktop.
Cassidoo 8.4.23
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
""" 8.3.2023""" | |
""" | |
[Cassidoo] Given two strings s and t, return true if t is an anagram of s, and false otherwise. Try this | |
in a language you're not comfortable with!""" | |
def anagram(string1, string2): | |
def dict_maker(string): | |
dict = {} | |
for char in string: | |
if char not in dict: | |
dict[char] = 0 | |
dict[char] += 1 | |
sorted_dict = {key: value for key, value in sorted(dict.items())} | |
return sorted_dict | |
dict1, dict2 = dict_maker(string1), dict_maker(string2) | |
if dict1 == dict2: | |
return True | |
else: | |
return False | |
print(anagram("noslia", "alison")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment