Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def anagram( a, b):
- s1 = a.lower()
- s2 = b.lower()
- if( len(s1) != len(s2)):
- return 0
- l = len( s1)
- d = {}
- for i in range( l):
- d[ s1[i]] = d.get( s1[i], 0) + 1
- d[ s2[i]] = d.get( s2[i], 0) - 1
- for i in d:
- if( d[i] != 0):
- return 0
- return 1
- s1 = 'juch'
- s2 = 'chuj'
- anagram( s1, s2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement