File tree Expand file tree Collapse file tree 1 file changed +3
-18
lines changed Expand file tree Collapse file tree 1 file changed +3
-18
lines changed Original file line number Diff line number Diff line change @@ -15,24 +15,9 @@ def group_words(key: str, value: list[str]):
15
15
pass
16
16
17
17
18
- def is_similar (source_word : str , other_word : str ) -> bool :
19
- """
20
- # get the length of the other_word
21
- # rotate all possible forms (right to left)
22
- #iterate through the lenght of the word and rotate_word()
23
- # compare each rotation with the source
24
- # if they match return True
25
- # else return False
26
- """
27
-
28
- is_similar = False
29
- for i in range (len (other_word )):
30
- new_form = rotate_word (other_word , i )
31
- is_similar = new_form == source_word
32
- if is_similar :
33
- break
34
-
35
- return is_similar
18
+ def is_similar (a : str , b : str ) -> bool :
19
+ """Check if b is a rotation of a"""
20
+ return len (a ) == len (b ) and b in (a + a )
36
21
37
22
38
23
def rotate_word (word : str , count_of_rotation : int ) -> str :
You can’t perform that action at this time.
0 commit comments