MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / anagram_checker

Function anagram_checker

Python/anagram_checker.py:1–19  ·  view source on GitHub ↗
(s1,s2)

Source from the content-addressed store, hash-verified

1def anagram_checker(s1,s2):
2 list1 = list(s1)
3 list2 = list(s2)
4
5 list1.sort()
6 list2.sort()
7
8 pos = 0
9 matches = True
10 if len(list1) != len(list2):
11 return False
12
13 while pos < len(s1) and matches:
14 if list1[pos] == list2[pos]:
15 pos = pos + 1
16 else:
17 matches = False
18
19 return matches
20
21# Example -
22# print(anagram_checker('abcde','edcba'))

Callers

nothing calls this directly

Calls 1

sortMethod · 0.45

Tested by

no test coverage detected