# Answer on Question #43113 - Programming - Python
from collections import Counter
def anagrams(s1, s2):
return Counter(s1) == Counter(s2)
def test():
assert anagrams('', '')
assert anagrams('a', 'a')
assert not anagrams('a', 'b')
assert anagrams('smart', 'marts')
assert anagrams('secure', 'rescue')
assert not anagrams('secure', 'rescu')
assert anagrams('abcabc', 'aabbcc')
print "Tests passed"
test()
Comments
Leave a comment