Skip to content

Instantly share code, notes, and snippets.

@athursto
Created August 4, 2023 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athursto/367cb90630ec93e53cb5fc5f67d04bcc to your computer and use it in GitHub Desktop.
Save athursto/367cb90630ec93e53cb5fc5f67d04bcc to your computer and use it in GitHub Desktop.
Cassidoo 8.4.23
""" 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