From fd38128f1b658a5d630b383da9a75dffb26126bb Mon Sep 17 00:00:00 2001 From: bhattbhavesh91 Date: Mon, 19 Jun 2017 16:50:51 +0000 Subject: [PATCH] Done --- build.py | 18 ++++++++++++++++++ build.pyc | Bin 0 -> 547 bytes tests/__init__.pyc | Bin 0 -> 168 bytes tests/test_is_rotation.pyc | Bin 0 -> 1068 bytes 4 files changed, 18 insertions(+) create mode 100644 build.pyc create mode 100644 tests/__init__.pyc create mode 100644 tests/test_is_rotation.pyc diff --git a/build.py b/build.py index e69de29..9ca16f4 100644 --- a/build.py +++ b/build.py @@ -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 diff --git a/build.pyc b/build.pyc new file mode 100644 index 0000000000000000000000000000000000000000..027ab18c41b5b843ae8ed0295788bc0bc0390fb9 GIT binary patch literal 547 zcmcIgO-sW-5S`sdtRKAzRusg8kV}p2$wCo9k)B$xLQxP&leGy=cWZVl73xX+YTMt`eMo5i2<%q~TLYv-Uqp{c1PwxoPQp+@Y#^=?b_qb> z=tPpO(^9PS@`xP9m=nyE9nY=u3v!YM%rDyHD&ztd`4s%#Je|^q-7EXYoCTZAF`XC15nNovNOn`X|!@&-NuDgzI9*DSFJMEV}*N(3Z=aS{NQVvtF7hd za-FJ0h&Fk!U1U*arYag`v2%boWwUlO8k%xqXK|vU#H1>Ev8h#!*}Kb(Zp7B+V?9;c zHJazGXf)4@^bFh%#B%#w8W+3VX#VeZ4?v-ietdjpUS>&rydF>y2hdcT-29Z%oK!oI-Niu6004l-DAoV~ literal 0 HcmV?d00001 diff --git a/tests/test_is_rotation.pyc b/tests/test_is_rotation.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8f8b5def79f4e31ac5c68ef80472213a1a728ed8 GIT binary patch literal 1068 zcmcgqO>fgc5S_Ktub_&y>V*sH(LxHQhzk-zh^nAoa!4wb^kO;LH8Hh!gLjP7s+__v z;=qNU#Seft>x$%nIM(*Q-SN!MzIn6puigI7@9!rwx_e^GZ!r85fX1h&BB~W#DpEQk zqo`1%WBNw4B$`}Cq=It9 z=!5*|(Jl7%NN>-EDAVO26QYfDllUr-sy~K-c0kGV0B9bB+>-bM>K8AN{?ha%Xw$@ z!Zm!_G(fR)?@hz+@(R6L*{7e|yb9YpPY;npXAR5ZylG7m5{l(bRfO~j3<}^USfz7U zn{+zQnE_vnpT9g#FI;ow7x~PjGp9{jcSynsURxn3${Z{Pnp@fn2 kG>9iMZmQvmV{1#6;zn>#h`U#2L8n)pGOvZD7lwQBAF${5!2kdN literal 0 HcmV?d00001