Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def is_rotation(s1,s2):
if s1 == None or s2 == None:
return False
if s1 == '':
if s2 == '':
return True
return False

for index in range(len(s1)):
# Keep iterating through the 1st index and keep pushing the 1st value to the last.
# if the string matches to the 2nd string then it its rotational.
# i = 0 --> s[0:] + s[] = s2 ? -- ABCD + [] = CDAB (No)
# i = 1 --> s[1:] + s[1] = s2? --- BCD + A = CDAB (No)
# i = 2 --> s[2:] + s[0:2] = s2? -- CD + AB = CDAB (Yes)
# Hence rotational
if s1[index:]+s1[0:index] == s2:
return True
return False
Binary file added build.pyc
Binary file not shown.
Binary file added tests/__init__.pyc
Binary file not shown.
Binary file added tests/test_is_rotation.pyc
Binary file not shown.